我在使用Plot.ly Double Axis图格式化轴时遇到问题。我试图得到一个y轴在数字前面包含'$'符号,但我无法找到任何代码。希望有人可以帮我解决这个问题。
ay <- list(
tickfont = list(color = "red"),
overlaying = "y",
side = "right"
)
p <- plot_ly(data = df, x = days, y = sales, name = "Sales",type="bar") %>%
add_trace(x = days, y = Sales/Day, name = "Sales/Day", yaxis = "y2") %>%
layout(title = "Double Y Axis", yaxis2 = ay)
所以在上面的代码中我想为两个y轴(Sales和Sales / day)添加一个'$'符号。
答案 0 :(得分:0)
由于您没有提供可重现的示例,我将使用plotly
网站上的示例。你可以尝试:
library(plotly)
ay <- list(
tickfont = list(color = "red"),
overlaying = "y",
side = "right"
)
plot_ly(x = 1:3, y = 10*(1:3), name = "slope of 10") %>%
add_trace(x = 2:4, y = 1:3, name = "slope of 1", yaxis = "y2") %>%
layout(title = "Double Y Axis", yaxis2 = ay, yaxis = list(showtickprefix = "all", tickprefix = "$"))