问题
EDIT: Regarding my question 2, it seems it is a bug and hasn't been fixed yet as it is not their top priority at the moment. Someone asked to try katex instead of latex, but not sure how that works https://github.com/plotly/plotly.js/issues/559
I have attached an output for a code- https://i.stack.imgur.com/u65if.jpg.
I am trying to plot two y axis and a common x axis using plotly. The issues I am facing are:
I would like the primary and the secondary y axis ticks to share the same gridline. A you can see from the graph, it is not the case. Should I manually change the range? How do I force it to merge with primary y axis gridline?
The hoverlabels don't convert to latex format inspite of using TeX. As you can see from the pic, they stay as \alpha instead of the greek letter
Will renderplotly() work in Shiny with the secondary axis? I am yet to play with it and wanted to know if I should approach it differently.
Here is my code
library(latex2exp)
library(ggplot)
library(plotly)
foo<-data.frame("x"=seq(0,100,1),"y"=rnorm(101),"z"=rnorm(101))
ay <- list(
overlaying = "n",
side = "left"
)
ay2 <- list(
overlaying = "y",
side = "right"
)
fig <- plot_ly()%>%
add_lines(data=foo,x = ~x, y = ~y,name=TeX("\\alpha") ,line = list(color="blue"))%>%
add_lines(data=foo,x = ~x, y = ~z,name=TeX("\\beta") , yaxis = "y2",line = list(color="red"))%>%
layout(
yaxis=ay,
yaxis2 = ay2,
hoverlabel = list(font=list(size=20))
)
config(fig,mathjax = 'cdn')
[1]: https://i.stack.imgur.com/u65if.jpg
来源:https://stackoverflow.com/questions/61052883/secondary-axis-in-ploty-for-r-and-shiny