4

I am using ggplotly to make plotly graphs and have been using sec.axis to label my facets in ggplot2. Like this: ggplot

After this I try to pass the ggplot object to ggplotly and the sec.axis disappears. I tried to add a second yaxis in layout() but it does not seem to work. How can I label my facets in plotly similar to using sec.axis() in ggplot2?

library(ggplot2)

library(plotly)

p1 <- ggplot(mtcars)+
      geom_point(aes(x = cyl , y = mpg))+
      facet_grid(vs~am)+
      scale_y_continuous("MPG", sec.axis = sec_axis(~., name = "VS") )+ 
      theme(strip.placement = "outside")

ay <- list(
  tickfont = list(size=11.7),
  titlefont=list(size=14.6),
  overlaying = "y",
  nticks = 5,
  side = "right",
  title = list(
  text = "Second y axis",
  standoff = 0)
)

ggplotly(p1) %>%
  layout(yaxis2 = ay)
Mike
  • 3,797
  • 1
  • 11
  • 30

1 Answers1

1

Unfortunately it doesn't seem to be possible at this time, but maybe in the future? For more info:

filups21
  • 1,611
  • 1
  • 19
  • 22