Reputation: 1247
Let's consider the following plot:
p1 <- plot_ly(
x = c("giraffes", "orangutans", "monkeys"),
y = c(20, 14, 23),
name = "Size",
type = "bar")
p2 <- plot_ly(
x = c("giraffes", "orangutans", "monkeys"),
y = c(10, 2, 3),
name = "Weight",
type = "bar"
)
p <- subplot(p1, p2, nrows = 2, shareX = TRUE)
p %>% layout(yaxis = list(title = "Size"))
I would like to control the y-axis title of each subplot. It looks like the way I am doing it I only manage to control the top subplot. How can I also add a title for the y-axis of the bottom subplot?
Upvotes: 1
Views: 1355
Reputation: 2829
titleY = TRUE
will make the difference, such that:
p1 <- plot_ly(
x = c("giraffes", "orangutans", "monkeys"),
y = c(20, 14, 23),
name = "Size",
type = "bar")%>%layout(yaxis = list(title = c("Size1")))
p2 <- plot_ly(
x = c("giraffes", "orangutans", "monkeys"),
y = c(10, 2, 3),
name = "Weight",
type = "bar"
)%>%layout(yaxis = list(title = c("Size2")))
p <- subplot(p1, p2, nrows = 2, shareX = TRUE, titleY= TRUE)
p
Upvotes: 6