我在plotly::plot_ly
观察到一个奇怪的选择,在指定组着色时为错误条着色:
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))
如何指定每个点应与其错误栏具有相同的颜色?
答案 0 :(得分:1)
如果您有color = type
,请切换到group = type
以获得所需的分组。
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))