[R] How can I fit the secondary y axis legend on my graph?

From: Chris Grobler <bjorn.grobler_at_zoo.ox.ac.uk>
Date: Sun 03 Sep 2006 - 18:39:26 GMT


Dear All,

   Having a bit of trouble with plotting two y variables on the same graph. I cannot manage to get the secondary y axis label on to the right of the axis - it gets plotted beyond the graphic window I assume?! The way I constructed the graph is thus:

plot(data[,3],data[,2],axes=F, type="b") ## plots my data from two data colums without axes - fine

axis(1, at=data[,3])                                     ## adds my 
primary axis - fine
mtext("Year", side=1, line=2)                     ## Adds the title 

"Year" - fine

axis(2)
mtext("Index of population size", side=2, line=2) ## Puts the primary y axis on and names it correctly
points(data[,3],data[,1],pch=16)                 ## puts my secondary y 
points on - also fine
axis(4)
mtext("Number of sun hours in April", side=4, line=2) ## if I enter
"line=1" it writes over my inex numbers but if I put
                                                                        
        "line=2" it disappears.

I assume that perhaps the graph automatically fills the space and does not leave any for 'odd' axes. My questions therefore are: how can I get the legend on that axis, how do I remove ylab and xlab to free the space that they take (as they spaced by default at "line=3" and thus waste space - I would like to set them to "line=2") and perhaps how do I scrunch up the x-axis so that it leaves more space at either side?

Sorry for the ignorance!

Chris



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon Sep 04 04:45:24 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 07 Sep 2006 - 07:51:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.