I'm trying to display a bar chart with error bars. When I add a color variable, the error bars are displayed on the wrong bars.
df <- data_frame(label = c("Step 1", "Step 2", "Step 3", "Step 4"),
Action = c("DISPENSE", "WAIT", "DISPENSE", "WAIT" ),
Avg = c(1.65, 3.88, 1.19, 23.09),
StdDev = c(0.80, 7.54, 0.11, 14.63))
p1 <- plot_ly(df, type = "bar", orientation = 'h',
y = ~label, x = ~Avg, color = ~Action,
error_x = list(type = "data", array = ~StdDev, color = "#000000"),
text = ~paste0(Avg," (+/- ",StdDev,")"), hoverinfo = "text")
p2 <- plot_ly(df, type = "bar", orientation = 'h',
y = ~label, x = ~Avg,
error_x = list(type = "data", array = ~StdDev, color = "#000000"),
text = ~paste0(Avg," (+/- ",StdDev,")"), hoverinfo = "text")
subplot(p1, p2, nrows=2)
this is the output of the plot:
I want the chart to be colored by Action, like in p1
, but with the error bars correctly assigned for each row, like in p2
.
I've tried various forms for the error_x
parameters, without success:
error_x = ~list(type = "data", array = StdDev, color = "#000000")
error_x = ~list(type = "array", array = StdDev, color = "#000000")
error_x = list(type = "array", array = ~StdDev, color = "#000000")
I suspect it's similar to this problem, or they're both caused by the same bug. I wasn't able to implement their solutions.