使用ggplot将同一轴命名为许多图形

问题描述 投票:-1回答:1

我有一个列表,其中包含其他列表,此列表的内容是测量的总太阳辐射的变量,我制作了一个循环以在同一窗口中绘制此列表,但我将为所有名称指定相同的y轴和x轴图形而不是每个图的单个轴。顺带一提,我想用每个列表的名称来命名每个图(即“ Aguachica”,“ Apto Ernesto Cortissoz”,“ Carmen deBolívar” ...)。

我的清单清单是这个

List of lists

head(my.data$Aguachica)
A tibble: 6 x 3
date                   MS_NR VALUE
<dttm>                 <dbl> <dbl>
1 2016-07-08 00:00:00 23195240  454.
2 2016-07-09 00:00:00 23195240  615.
3 2016-07-10 00:00:00 23195240  412.
4 2016-07-11 00:00:00 23195240  387.
5 2016-07-12 00:00:00 23195240  559.
6 2016-07-13 00:00:00 23195240  493.

现在有一个循环来绘制列表

plot_lst <- list()

for (i in 1:length(DayRad)) {
df1 =as.data.frame(DayRad[[i]])
plotdf1 <- ggplot(bind_rows(df1, .id="Estaciones"), aes(x = date, y = VALUE)) +
geom_line(na.rm = TRUE) + xlab("Time (years)") + ylab(as.expression(bquote("Global Solar          Radiation" ~ (W/m^2)))) +
theme_bw() +stat_smooth(mehotd = "GAM", colour = "red") + theme(text = element_text(size = 4))
plot_lst[[i]] <- plotdf1
}

Plot_Rad <- marrangeGrob(plot_lst, nrow = 6, ncol = 2)
Plot_Rad

结果是这个

enter image description here

所以我想对轴进行泛化,x =时间(年),y =全球太阳辐射”〜(W / m ^ 2)。

感谢您的回复。

r ggplot2 plot graph axes
1个回答
0
投票

这未经测试,但应该可以。它:

© www.soinside.com 2019 - 2024. All rights reserved.