【发布时间】:2021-09-05 22:59:08
【问题描述】:
我正在尝试保存多个 ggplots,这些 ggplots 本质上是对每列进行直方图。理想情况下,我希望每页有 2 或 3 个图表,但现在我可以每页只有 1 个。 ggplots 看起来不错,但我似乎无法正确保存 ggplots(尽管可能没有正确保存)。
item_set <- unique(df$Item_number)
for(i in 1:length(item_set)){
n <- as.character(item_set[i])
temp <- wide_data[, grep(n, names(wide_data))]
temp <- temp[, grep("Time", names(temp))]
coln <- colnames(temp)
ggplot(data = temp, aes_string(x = coln)) + geom_histogram(color = "black", fill = "white", bins = 70)
ggsave("Time Spent - Entire Sample.pdf")
}
因此,对于每个 ggplot,它基本上只是逐列、按列名(coln)并创建一个直方图。如何将所有这些保存到一个 pdf 中?
【问题讨论】:
-
请提供足够的代码,以便其他人更好地理解或重现问题。