It seems like every time I try to do something a little different, I cannot get output saved just right. This is on RedHat 7.2 with R 1.4.1. The png output looks fine, but the eps output has the problem that the bounding box on the legend cuts the legend in half. I put a copy of a bad one here: http://lark.cc.ukans.edu/~pauljohn/ResearchPapers/meanProtest-box.eps When I asked about these chores about 6 months ago, I got some tips which have worked other times. I had the impression that if I set the size of the x11 device to match the eventual ps output size, then all would be OK. But its not this time. Here's my code: dat <- read.table("a816bstat7vis.csv",header=T); attach(dat) x11(height=6, width=6,pointsize=12) plot (pop,meanProtWnoActivists,pch=22, main="Mean Protest Level During Experiment",xlab="population",ylab="mean protest",ylim=c(0,100)); points(pop,meanProtW10Activists,pch=23,col="blue") points(pop,meanProtW20Activists,pch=24,col="red") legend(locator(1),c("w/0 activists","w/10 activists","w/20 activists"),pch=c(22,23,24),col=c("black","blue","red")) dev.copy(device=postscript,file="meanProtest.eps",width=6,height=6,pointsize=12) dev.off() dev.copy(device=png,file="meanProtest.png",width=500,height=500) dev.off() I tried doing this with the postscript device on, but then I couldn't see a graph to use my locator for the legend, so I reverted to this draw-first, write-later way. If I change the legend command to not draw the bounding box, then the output is OK, but I'm still asking! I put copies of those pictures in the same directory referred to above. Incidentally, I used a Windows machine last week and the EMF output is slick and easy to make. As I was using it, I was wondering if the size of the Window in which the graphic was being displayed had an impact on the output that was created by EMF or PS in Windows. It seemed to not be affected, as it is in X11 systems. Is this true? -- Paul E. Johnson email: pauljohn at ukans.edu Dept. of Political Science http://lark.cc.ku.edu/~pauljohn University of Kansas Office: (785) 864-9086 Lawrence, Kansas 66045 FAX: (785) 864-5700 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Paul Johnson <pauljohn at ku.edu> writes:> http://lark.cc.ukans.edu/~pauljohn/ResearchPapers/meanProtest-box.eps > > When I asked about these chores about 6 months ago, I got some tips > which have worked other times. I had the impression that if I set the > size of the x11 device to match the eventual ps output size, then all > would be OK. But its not this time. > > Here's my code: > > dat <- read.table("a816bstat7vis.csv",header=T); > attach(dat) > > x11(height=6, width=6,pointsize=12) > > plot (pop,meanProtWnoActivists,pch=22, main="Mean Protest Level During > Experiment",xlab="population",ylab="mean protest",ylim=c(0,100)); > > points(pop,meanProtW10Activists,pch=23,col="blue") > > points(pop,meanProtW20Activists,pch=24,col="red") > > legend(locator(1),c("w/0 activists","w/10 activists","w/20 activists"),pch=c(22,23,24),col=c("black","blue","red")) > > dev.copy(device=postscript,file="meanProtest.eps",width=6,height=6,pointsize=12) > dev.off() > dev.copy(device=png,file="meanProtest.png",width=500,height=500) > dev.off()Hm? I don't have your data file, but this works for me: x11(height=6, width=6, pointsize=12) plot(1) legend(locator(1),c("w/0 activists","w/10 activists", "w/20 activists"),pch=c(22,23,24),col=c("black","blue","red")) dev.copy(device=postscript,file="meanProtest.eps", width=6,height=6,pointsize=12) dev.off() Looks like all your point markers and fonts have become inflated somehow? -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Sat, 13 Apr 2002, Paul Johnson wrote:> It seems like every time I try to do something a little different, I > cannot get output saved just right. > > This is on RedHat 7.2 with R 1.4.1. > > The png output looks fine, but the eps output has the problem that the > bounding box on the legend cuts the legend in half. I put a copy of a > bad one here: > > http://lark.cc.ukans.edu/~pauljohn/ResearchPapers/meanProtest-box.eps > > When I asked about these chores about 6 months ago, I got some tips > which have worked other times. I had the impression that if I set the > size of the x11 device to match the eventual ps output size, then all > would be OK. But its not this time.It's not so. Matching sizes and pointsizes helps a great deal, but the idea of copying graphs by replaying the display list (as used by R and S) is fundamentally limited. I do this by using the postscript device directly and by experimenting with where to put the legend. One fundamental limitation is that font metrics will be computed on the X11 device, but the PS device will layout the text. I think that is what you are seeing here. You may just be being caught by rounding in the pointsize requested: as I recall it on X11 the pointsize is approximated by the available fonts. (On the postscript() device it is for some reason rounded down. On X11 what happens depends on the screen dpi, for example.)> Here's my code: > > dat <- read.table("a816bstat7vis.csv",header=T); > attach(dat) > > x11(height=6, width=6,pointsize=12) > > plot (pop,meanProtWnoActivists,pch=22, main="Mean Protest Level During > Experiment",xlab="population",ylab="mean protest",ylim=c(0,100)); > > points(pop,meanProtW10Activists,pch=23,col="blue") > > points(pop,meanProtW20Activists,pch=24,col="red") > > legend(locator(1),c("w/0 activists","w/10 activists","w/20 > activists"),pch=c(22,23,24),col=c("black","blue","red")) > > dev.copy(device=postscript,file="meanProtest.eps",width=6,height=6,pointsize=12) > dev.off() > dev.copy(device=png,file="meanProtest.png",width=500,height=500) > dev.off() > > > I tried doing this with the postscript device on, but then I couldn't > see a graph to use my locator for the legend, so I reverted to this > draw-first, write-later way. > > If I change the legend command to not draw the bounding box, then the > output is OK, but I'm still asking! I put copies of those pictures in > the same directory referred to above. > > Incidentally, I used a Windows machine last week and the EMF output is > slick and easy to make. As I was using it, I was wondering if the size > of the Window in which the graphic was being displayed had an impact on > the output that was created by EMF or PS in Windows. It seemed to not be > affected, as it is in X11 systems. Is this true?EMF, yes, ps no. The issue is that the screen device and EMF are sharing the same fonts and hence font metrics, whereas PS is not. You may do better because the on-screen font size is approximated less: Windows is using (by default) scaleable fonts whereas X11() is not. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._