plotly.R icon indicating copy to clipboard operation
plotly.R copied to clipboard

Error bars (using error_y) are no longer positioned correctly when missing data is present

Open lennartraman opened this issue 2 years ago • 0 comments

Error bars (using error_y) are no longer positioned correctly when missing data is present using the barplot plot type. Plotly version 4.10.1.

Reproducible example:

library(plotly)
library(plyr)

data_mean <- ddply(ToothGrowth, c("supp", "dose"), summarise, length = mean(len))
data_sd <- ddply(ToothGrowth, c("supp", "dose"), summarise, length = sd(len))
data <- data.frame(data_mean, data_sd$length)
data <- rename(data, c("data_sd.length" = "sd"))
data$dose <- as.factor(data$dose)

data[1, "length"] <- NA # adding missing data
data[1, "sd"] <- NA # adding missing data

fig <- plot_ly(data = data[which(data$supp == 'OJ'),], x = ~dose, y = ~length, type = 'bar', name = 'OJ',
               error_y = ~list(array = sd,
                               color = '#000000'))
fig <- fig %>% add_trace(data = data[which(data$supp == 'VC'),], name = 'VC')

fig

image

lennartraman avatar Sep 26 '23 09:09 lennartraman