Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
264 views
in Technique[技术] by (71.8m points)

r - Plots with good resolution for printing and screen display

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There is a small error in your original png command. Try this:

png(file="mag_feb.png", units="in", width=11, height=8.5, res=300)

Now, width and height are in inches, and res is in pixels/inch. Before, the res parameter was being ignored.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...