【发布时间】:2021-01-31 09:28:23
【问题描述】:
在 R plotly 中,我想显示一个在左侧和右侧都有 y 轴标签的单线图。我了解how to do this with 2 or more traces,但我找不到任何地方显示如何在图表上仅使用 1 条迹线进行操作。这是一个基本示例 - 它仅在左侧显示 y 轴,但我希望它出现在两侧:
library(plotly)
ay <- list(
tickfont = list(color = "red"),
overlaying = "y",
side = "right",
title = "second y axis"
)
fig <- plot_ly()
fig <- fig %>% add_lines(x = ~1:3, y = ~10*(1:3), name = "slope of 10")
fig <- fig %>% layout(
title = "Double Y Axis", yaxis2 = ay,
xaxis = list(title="x")
)
fig
【问题讨论】:
-
就是这样!添加透明度并关闭 hoverinfo 就可以了