Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Subplot y-axis names

Hi. I use subplot to merge some different plots together (with different y-axis names). In previous version of plotly evrth was ok, but now after subplotting all custom y-axis names dissapear. I see the same picture in documentation here https://cpsievert.github.io/plotly_book/merging-plotly-objects.html

How can i customize displaying y-axis name of each plot in subplotting layout?

Hey @pokynka,

You can use subplot(p1 , p2, titleY = TRUE) and fully customize each plot via adding %>% layout().

a <- list(
  title = "AXIS TITLE 1"
)

b <- list(
  title = "AXIS TITLE 2"
)


p1 <- plot_ly(economics, x = ~date, y = ~unemploy) %>% 
  add_lines(name = "unemploy") %>%
  layout(yaxis = a)
p2 <- plot_ly(economics, x = ~date, y = ~uempmed) %>% 
  add_lines(name = "uempmed") %>%
  layout(yaxis = b)
subplot(p1, p2, titleY = TRUE)

Cheers,
Branden

2 Likes