Pooia
Pooia

Reputation: 41

How to add mean value to a BoxPlot using Plotly in R?

Creating a boxplot with Plotly library in R is straightforward as follows:

library (plotly)

x <- 1:100

plot_ly (x = ~x, type = 'box' )

But, by default it gives me median, while I want the value of Mean instead. I know that I can change this with schema() but I could not figure it out how. I also do not want to calculate it myself and then add that to the plot, I want the plot to do it by changing that default behavior.

Cheers

Upvotes: 0

Views: 1896

Answers (1)

JVP
JVP

Reputation: 329

Data with mean not equal the median:

x <- c(1:10, 40:50)

plot_ly (x = ~x, type = 'box', boxmean = T)

Upvotes: 4

Related Questions