Plotly: How to add a median line on a box plot
问题 I would like to add trace of a median line on my box plot. like this Here are my plots so far: library(plotly) p <- plot_ly(y = ~rnorm(50), type = "box") %>% add_trace(y = ~rnorm(50, 1)) p 回答1: Just start out with a scatter plot using plot_ly(..., type='scatter', mode='lines', ...) , and follow up with one add_boxplot(...' inherit=FALSE, ...) per box plot. Here's how you do it for an entire data.frame : Complete code with sample data: library(dplyr) library(plotly) # data df <- data.frame