我正在尝试在 R 中使用双轴绘图plotly
。但是,我无法使用我在这里找到的以下代码命名第一个 y 轴:https ://plot.ly/r/multiple-axes/
library(plotly)
ay <- list(
tickfont = list(color = "red"),
overlaying = "y",
side = "right",
title = "second y axis"
)
p <- plot_ly() %>%
add_lines(x = ~1:3, y = ~10*(1:3), name = "slope of 10") %>%
add_lines(x = ~2:4, y = ~1:3, name = "slope of 1", yaxis = "y2") %>%
layout(
title = "Double Y Axis", yaxis2 = ay,
xaxis = list(title="x")
)
如果有人可以提供一些建议,我将不胜感激。