【问题标题】:Title of Subplots in PlotlyPlotly 中的子图标题
【发布时间】:2017-12-25 07:33:02
【问题描述】:

我正在尝试在 Plotly 中制作一个 3x3 子图的网格。我正在尝试获取每个子图的标题和顶部的主标题,但我似乎无法让它工作。 我在 Python 中看到了这个 wonderful site,但我似乎找不到 R 的等价物。

all <- subplot(graph1, graph2, graph3, graph4, graph5, graph6, 
graph7, graph8, graph9, nrows = 3)

这给了我想要的网格,但在子图上没有我想要的标题:

1. Graph 1 
2. Graph 2
3. Graph 3
4. Graph 4
5. Graph 5
6. Graph 6
7. Graph 7
8. Graph 8 
9. Graph 9

默认的主标题是图 9。

有人可以帮忙吗?

【问题讨论】:

标签: r plotly


【解决方案1】:

您可以使用 ggplot + plotly 来实现它。这就是诀窍:

library(ggplot2)
library(plotly)

mtcars$main1 = "title1"
mtcars$main2 = "title2"

p1 = ggplot(mtcars, aes(x = mpg, y = cyl)) + geom_point() + facet_wrap(~main1) 
p2 = ggplot(mtcars, aes(x = disp, y = hp)) + geom_point() + facet_wrap(~main2) 

plotly::subplot(p1, p2 ,nrows = 1, margin = 0.23 ) %>% layout(title ="Main title")

【讨论】:

    猜你喜欢
    • 2022-06-11
    • 2020-05-14
    • 1970-01-01
    • 2019-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-22
    • 2019-01-06
    相关资源
    最近更新 更多