You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何提升R语言绘制的科研论文用柱状图的输出分辨率

R语言绘制科研论文柱状图提升分辨率的解决方案

你当前使用R默认png()函数导出图片时,默认分辨率仅为72dpi,远低于科研论文普遍要求的300dpi及以上的标准,因此输出图片清晰度不足,可通过以下方法解决:

  • 调整png函数的分辨率参数
    给png()函数添加res参数设置分辨率(建议设为300~600dpi,符合绝大多数期刊要求),同时搭配width、height参数设置画布尺寸,units参数指定尺寸单位,避免调高分辨率后图片元素被压缩。
  • 优先导出矢量图格式
    选择tiff、pdf等矢量格式导出图片,矢量图可无限放大不会出现失真模糊的问题,完全满足科研出版要求,可直接替换png()函数为tiff()或pdf()。
  • 同步调整文字缩放参数
    分辨率调高后默认的坐标轴、标题、图例文字会偏小,可通过cex.axis(坐标轴文字缩放)、cex.lab(轴标题缩放)、cex.main(主标题缩放)参数调整文字大小,保证可读性。

修改后的完整可运行代码如下:

# 准备绘图数据
PanelB <- structure(c(0, 0, 0, 0, 1, 16, 2, 12, 6, 14, 38, 29, 56, 31, 
181, 59, 251, 58), .Dim = c(2L, 9L), .Dimnames = list(NULL, c("2013", 
"2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021"
)))
colors = c("black","grey")
years <- c("2013","2014","2015","2016","2017","2018","2019","2020","2021")
sectors <- c("Financials","Industrials")

# 导出300dpi高分辨率png示例,画布尺寸为7*5英寸
png(file = "Panel B.png", width = 7, height = 5, units = "in", res = 300)

# 绘制柱状图,调整文字大小适配高分辨率
barplot(PanelB, main = "Panel B. Numbers of corporate green bonds issued", 
        names.arg = years, xlab = "Years", ylab = "Number of green bonds issued", 
        col = colors, cex.main = 1.2, cex.lab = 1.1, cex.axis = 0.9)

# 添加图例
legend("topleft", sectors, cex = 1.1, fill = colors)

# 关闭绘图设备完成保存
dev.off()

# 若需要导出无损压缩矢量tiff格式,替换上述png函数为以下代码即可
# tiff(file = "Panel B.tiff", width = 7, height = 5, units = "in", res = 300, compression = "lzw")

内容的提问来源于stack exchange,提问作者thomas.diridondo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.24 09:09:05