但是当尝试使用 fill = "tozeroy" 时,情节看起来像这样:
忽略 y0 的值
所以,我想将区域从线条填充到 y0 值,而不是绝对零。
代码示例:
library(plotly)
library(magrittr)
x <- seq.Date(as.Date("2017/01/01"), as.Date("2017/12/31"), by = 1)
y1 <- rnorm(365, 100, 10)
y2 <- rnorm(365, 100, 10)
dat <- data.frame(x, y1, y2)
plot_ly(dat, x = ~x, y = ~y1, mode = "lines", type = "scatter", fill = "tozeroy", y0 = 80, name = "y1") %>%
add_trace(dat, x = ~x, y = ~y2, fill = 'tozeroy', y0 = 80, name = "y2")%>%
layout(xaxis = list(title = ""), yaxis = list(title = ""))
忽略y0 = 80
参数。