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

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Sun 03 Sep 2006 - 18:51:49 GMT

?par, specifically mar and mai, xaxt and yaxt. Note that there are my default on 2.1 lines in the right margin and 4.1 in the left one.

You should find the description in 'An Introduction to R' helpful.

On Sun, 3 Sep 2006, Chris Grobler wrote:

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

-- 
Brian D. Ripley,                  ripley@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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
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:56:19 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.