[R] trouble getting output from graphs, again

Paul Johnson pauljohn at ku.edu
Sun Apr 14 00:28:27 CEST 2002


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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list