【发布时间】:2020-01-08 01:25:48
【问题描述】:
由于ggplotly 不支持ggplot2 的sec.axis (Adding second Y axis on ggplotly),所以我想向情节对象添加第二个轴。但是,我不想添加任何新的痕迹。
示例:
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")
)
p
如何在没有add_lines 或添加任何其他跟踪的情况下完成显示yaxis = "y2"?
【问题讨论】: