Plotly: Annotate outliers with sample names in boxplot

后端 未结 4 1791
滥情空心
滥情空心 2021-01-06 16:09

I am trying to create a boxplot with ggplot and plotly with the dataset airquality where Month is on the x-axis and Ozone values are o

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-06 16:13

    I found solution on https://github.com/ropensci/plotly/issues/887

    Try to make this kind of code !

     library(plotly)
    
     vals <- boxplot(airquality$Ozone,plot = FALSE)
     y <- airquality[airquality$Ozone > vals$stats[5,1] | airquality$Ozone < vals$stats[1,1],]
    
    plot_ly(airquality,y = ~Ozone,x = ~Month,type = "box") %>% 
       add_markers(data = y, text = y$Day)
    

提交回复
热议问题