Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Plot.ly R中的双轴格式化内容_R_Formatting_Data Visualization_Plotly - Fatal编程技术网

Plot.ly R中的双轴格式化内容

Plot.ly R中的双轴格式化内容,r,formatting,data-visualization,plotly,R,Formatting,Data Visualization,Plotly,使用Plot.ly双轴图形格式化轴时遇到问题。我试图让其中一个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 = d

使用Plot.ly双轴图形格式化轴时遇到问题。我试图让其中一个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中添加一个“$”符号

由于您没有提供可复制的示例,我将使用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 = "$"))

欢迎来到StackOverflow。请打个招呼,谢谢你的回复。很抱歉没有添加代码,我已将代码添加到编辑版本中,幸运的是,您提供了网站上的示例以及我问题的答案。我将确保下次添加代码。