What is the R plot_ly command to add horizontal significance bars (and stars) to a plotly graph? The answers to "How to draw the boxplot with significant level?" and "Put stars on ggplot barplots and boxplots - to indicate the level of significance (p-value)" provide good code for ggplot.
First, determine significance:
library(lsmeans)
lsmeans(lm(data = iris, Sepal.Width ~ Species), pairwise ~ Species)
$contrasts
contrast estimate SE df t.ratio p.value
setosa - versicolor 0.658 0.06793755 147 9.685 <.0001
setosa - virginica 0.454 0.06793755 147 6.683 <.0001
versicolor - virginica -0.204 0.06793755 147 -3.003 0.0088
Here is example R code for the plot. How do I add lines and stars?
library(plotly)
p <- plot_ly()
p <- add_boxplot(p, data = iris, x = ~Species, y = ~Sepal.Width,
color = ~Species, boxpoints = "all", jitter = 0.3, pointpos = 0)
# p <- add_paths(p, data = iris, ???)
# p <- add_line(p, data = iris, ???)
p