Я создаю R
plotly
boxplot
для этих данных:
set.seed(1)
df <- data.frame(value = rnorm(100),
value.error. = runif(100,0.01,0.1),
treatment = rep(LETTERS[1:10], 10),
replicate = rep(1:10, 10), stringsAsFactors = F)
df$treatment <- factor(df$treatment)
Где в каждом поле я добавляю реплики в виде точек:
library(dplyr)
plotly::plot_ly(x = df$treatment, split = df$treatment, y = df$value,
type = "box", showlegend = F, color = df$treatment,
boxpoints = F, fillcolor = 'white') %>%
plotly::add_trace(x = df$treatment, y = df$value, type = 'scatter', mode = "markers",
marker = list(size = 8), showlegend = F, color = df$treatment)
Который дает:
Теперь я хотел бы добавить вертикальные полосы погрешностей к каждой точке (согласно df$value.error
).
Этот:
plotly::plot_ly(x = df$treatment, split = df$treatment, y = df$value,
type = "box", showlegend = F, color = df$treatment,
boxpoints = F, fillcolor = 'white') %>%
plotly::add_trace(x = df$treatment, y = df$value, type = 'scatter', mode = "markers",
marker = list(size = 8), showlegend = F, color = df$treatment) %>%
plotly::add_trace(error_y = list(array = df$sd), showlegend = F)
Дает мне тот же сюжет, что и выше.
Однако, если я только нанесу точки и добавлю их ошибки, используя:
plotly::plot_ly(x = df$treatment, y = df$value,
type = 'scatter', mode = "markers",
marker = list(size = 8), showlegend = F, color = df$treatment) %>%
plotly::add_trace(error_y =list(array = df$sd), showlegend = F)
Я получаю очки с их вертикальными полосами погрешностей:
Итак, мой вопрос: как заставить работать поле + точки + шкала ошибок? И, если решение также может сочетать дрожание точек с их планками погрешностей, это будет еще лучше.