我的目标是在 R 中生成绘图,以便它可以很好地打印在信纸上。下面是我的例子:
library(cowplot)
sample_df <- data.frame(col_1=c(1,2,3), col_2=c(6,7,8))
plot_1 <-ggplot(data=sample_df, aes(x = col_1, y =col_2, group=1))+
geom_line()+ggtitle('Title 1')
plot_2 <-ggplot(data=sample_df, aes(x = col_1, y =col_2, group=1))+
geom_line()+ggtitle('Title 2')
width_letter = 6
height_letter = width_letter*8.5/11
pdf('outpdf_1.pdf', width=width_letter, height=height_letter)
plot_grid(plot_1, plot_2, labels = "AUTO", ncol = 2, align = 'v', scale = 0.65) +
theme(plot.margin = unit(c(2,2,2,2), "cm"))
dev.off()