绘图具有良好的打印和屏幕显示分辨率
我正在使用
dev.new(width=5.8, height=3)
par(mfrow=c(1,3),mar=c(1,1,2,1),oma=c(4,1,2,0),mgp=c(3, 0.5, 0))
plot(...)
、处理和粘贴它们到 Microsoft Word 中制作我的图。它们在 Word 中看起来非常好(我尝试了不同的宽度,直到找到一个效果很好的宽度),但是当我打印它们时,它们看起来很糟糕。经过一番网络搜索后,我发现打印分辨率至少应为 300ppi。因此,在对宽度和高度进行了永恒的摆弄之后,我得出了使绘图看起来大小相同但分辨率更高的代码:
png(file="mag_feb.png",width=1800,height=950,res=300)
它们现在打印时看起来不错,但在 Word 中看起来一点也不清晰(在屏幕上) )。会不会是尺寸的问题?是否有办法使图表在打印和屏幕上看起来都很好?我已经花了几个小时在这上面,想不出还有什么可以尝试的,所以任何帮助将非常感激!
谢谢!
I was making my plots using
dev.new(width=5.8, height=3)
par(mfrow=c(1,3),mar=c(1,1,2,1),oma=c(4,1,2,0),mgp=c(3, 0.5, 0))
plot(...)
and coping and pasting them into Microsoft Word. They look really good in Word (I tried different widths until I found one that worked well) but when I printed them they looked terrible. After some web searching I found the resolution for printing should be at least 300ppi. So after fiddling with widths and heights for an eternity I came out with code that makes the plots look the same size but with a better resolution:
png(file="mag_feb.png",width=1800,height=950,res=300)
They now look good when printed, but they don't look sharp at all in Word (on screen). Could it be a problem with size? Isn't there a way to make graphs that look good printed and on screen? I already spent hours with this and can't think of anything else to try, so any help will be very much appreciated!
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您的原始 png 命令中有一个小错误。试试这个:
现在,宽度和高度以英寸为单位,分辨率以像素/英寸为单位。之前,res 参数被忽略。
There is a small error in your original png command. Try this:
Now, width and height are in inches, and res is in pixels/inch. Before, the res parameter was being ignored.
对于要打印的绘图,您应该使用矢量格式(例如 PDF)。如果图像在打印时看起来不错,但在 Word 中却不然,则说明 Word 的缩小功能存在问题。您可能想尝试使用矢量 Windows 图元文件格式将内容导入到 Word 中。
You should be using a vector format, like PDF, for plots you will print. If the images look good when printed but not in Word, that is a problem with Word's downscaling feature. You might want to try using the vector Windows Metafile format to get things into Word.
正如 @awoodland 所说,您希望以矢量格式导出图形。
As @awoodland notes, you want to export graphs in a vector format.
我希望这不是迟到的回复,但我在 R 中保存最佳图片的工作流程如下:
1)使用“dev.copy2pdf”将图形直接从图形设备复制到 pdf 文件:
2)使用 imagemagick使用以下命令将 pdf 转换为高分辨率 png:
3) 可选 - 也可以使用 imagemagick,删除所有白色边框并仅保留重要的内容:
希望它有所帮助。
I hope this is not a late reply, but my workflow to save optimal pictures from within R is the following:
1) copy the figure straight from the graphic device to a pdf file, using "dev.copy2pdf":
2) use imagemagick to convert the pdf into a high-res png, using this command:
3) optional - also with imagemagick, remove all the white borders and leave only the contents that matter:
Hope it helps.