简体   繁体   中英

plotly error bar plot strange color scheme

I am observing a strange choice from plotly::plot_ly to color the error bars when a group coloring is specified:

library("data.table")
library("plotly")
dat <- data.table(
  low_diff = c(2, 3, 1)
  , high_diff = c(3, 4, 1)
  , point = c(10, 11, 9)
  , type = LETTERS[1:3]
)
plot_ly(data = dat, y = type, x = point, mode = "markers", color = type,
        error_x = list(type = "data", symmetric = FALSE,
                       array = high_diff, arrayminus = low_diff))

在此处输入图片说明

How can I specify that each point should have the same color as its error bar?

Where you have color = type , switch to group = type to get the desired grouping.

plot_ly(data = dat, y = type, x = point, mode = "markers", group = type,
        error_x = list(type = "data", symmetric = FALSE,
                       array = high_diff, arrayminus = low_diff))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM