如何在R中使用Plotly创建子图网格?
官方网站上有这个好的Python示例:
Python代码有rows=2
和cols=2
选项,但是在R中,subplot
函数只有nrows
参数,没有ncols
参数。
我尝试了这个在R中的示例,但是nrows
似乎没有按预期工作:
# Basic subplot
library(plotly)
p <- plot_ly(economics, x = date, y = uempmed)
subplot(p,p,p,p,
margin = 0.05,
nrows=2
) %>% layout(showlegend = FALSE)
他们排成一行而不是网格状。请参阅结果:
![enter image description here](https://istack.dev59.com/cAvxM.webp)
ggplotly
,就像这个一样。