导出的插图怎么检查?
按最终尺寸检查 PDF 里的面板字母、刻度和坐标轴标题。如果需要交位图,核对 PNG 的实际像素尺寸。示例直接用像素指定 PNG 的宽高,确保两边都达到向上取整后的要求。

我用 R 自带的 mtcars 数据画两张散点图,并用 patchwork 排版。如果还没安装 ggplot2 或 patchwork,请先安装。脚本会把两个文件保存到 R 当前的工作目录。
可直接运行的 R 示例
library(ggplot2)
library(patchwork)
theme_figure <- theme_classic(base_size = 7) +
theme(plot.tag = element_text(face = "bold"))
panel_a <- ggplot(mtcars, aes(wt, mpg)) +
geom_point(size = 1.2, colour = "#17665c") +
labs(x = "Weight (1,000 lb)", y = "Miles per gallon") +
theme_figure
panel_b <- ggplot(mtcars, aes(hp, mpg)) +
geom_point(size = 1.2, colour = "#17665c") +
labs(x = "Horsepower", y = "Miles per gallon") +
theme_figure
figure <- (panel_a | panel_b) + plot_annotation(tag_levels = "A")
ggsave("figure.pdf", figure, width = 89, height = 60, units = "mm")
ggsave("figure.png", figure, width = 1052, height = 709, units = "px", dpi = 300)
从零开始学习R语言

