gpt4 book ai didi

r - 如何使用 R 为 plot_ly 中的子图提供字幕

转载 作者:行者123 更新时间:2023-12-03 20:17:47 24 4
gpt4 key购买 nike

我想知道如何使用 plot_ly 为子图提供不同的字幕。请任何提示。在这种情况下,我获得了一个称号 BB。谢谢。

p <- subplot(
plot_ly(economics, x = date, y = uempmed)%>%layout(showlegend = FALSE, title="AA"),
plot_ly(economics, x = date, y = unemploy)%>%layout(showlegend = FALSE, title="BB"),
margin = 0.05
)

最佳答案

title布局中的属性是指整个绘图表面的标题,因此只能有一个。但是,我们可以使用文本注释为您的子图创建“标题”,例如:

p <- subplot(
plot_ly(economics, x = date, y = uempmed)%>%layout(showlegend = FALSE),
plot_ly(economics, x = date, y = unemploy)%>%layout(showlegend = FALSE),
margin = 0.05
)
p %>% layout(annotations = list(
list(x = 0.2 , y = 1.05, text = "AA", showarrow = F, xref='paper', yref='paper'),
list(x = 0.8 , y = 1.05, text = "BB", showarrow = F, xref='paper', yref='paper'))
)

关于r - 如何使用 R 为 plot_ly 中的子图提供字幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37285729/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com