【发布时间】:2022-01-04 09:29:02
【问题描述】:
所以从this post 我试图在第二个 y 轴上制作一个绘图条形图,负值表示为红色,正值表示为绿色....但不知何故颜色仍然是错误的....为什么?
t <- tibble("one" = c(1,2,3,4,5,6,7,8,9),
"two" = c(-5,6,9,-8,7,-1,5,2,1),
"three" = c(2,5,6,9,8,7,8,4,5))
Plot <-
plot_ly(t, x = ~one, y = ~three, type = 'scatter', mode = 'lines',
name = "three", line = list(color = "#ffc107")
)
Plot <- Plot %>%
add_trace(x = ~one, y = ~two, type = 'bar', name = "two",
color = ~two < 0, colors = c("#28a745", "#dc3545"),
yaxis = 'y2'
) %>%
layout(title = "test",
xaxis = list(titel = "one"),
yaxis = list(side = 'left', title = 'two',
showgrid = F, zeroline = F,
showline = T),
yaxis2 = list(side = 'right', overlaying = "y",
title = 'three',
showgrid = F, zeroline = F,
showline = T))
【问题讨论】:
标签: r plotly bar-chart r-plotly