让我们考虑以下情节:
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"))
我想控制每个子图的y轴标题。看来我的操作方式只能控制顶部子图。如何为底部子图的y轴添加标题?
答案 0 :(得分:1)
titleY = TRUE
将有所作为,例如:
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