【发布时间】:2021-01-26 14:44:15
【问题描述】:
直到现在我一直在循环并从 List 中保存一个 ggplot 我已经查看了另一个问题,但它没有工作。
myplots=list()
par(mfrow = c(1, 5))
for (i in 1:5) {
#name=paste("ggp", i, sep = "_")
p1 =ggplot(Turbine[[i]],
aes(x=Turbine[[i]]$TS,
y=Turbine[[i]]$Pv..turbine))+
geom_point(size=1)+
ggtitle(names(Turbine[i])
)
print(i)
print(p1)
myplots[[i]]= p1
}
multiplot(plotlist=myplots,cols=5)
plot_grid(ggp_1,ggp_2,ggp_3,ggp_4,ggp_5) #trying to save ggplot as variable name
我遇到的问题是当我想在 1 个绘图中开始绘制多个绘图时。我想要 5 列地块。
也许是 lapply 功能。好吗?
让数据成为现实
Turbine=list of listname
first listname= name(Turbine[1])
view(Turbine [[1]])
TS Pv..turbine
1 20
2 20
3 24
4 19
所以
【问题讨论】:
-
这能回答你的问题吗? Store multiple plots into a list using a function 之后你可以继续使用 cowplot::plot_grid 或使用 patchwork::wrap_plots 以列表作为参数