[R] specify axis range
Gavin Simpson
gavin.simpson at ucl.ac.uk
Tue Aug 31 19:55:04 CEST 2010
On Tue, 2010-08-31 at 17:18 +0100, Lathouri, Maria wrote:
> Dear all,
>
> I want to make a plot where I can specify the range of y axis. I am using the interaction.plot command and because the values of y axis are from 2 to 500, I am using a logarithmic scale.
>
> >interaction.plot(speclong$Date,speclong$time2,speclong$outcome,xaxt="n",type="l",pch=20,xlab="", log="y", ylab="Concentration (ug/L)",trace.label="",col=rainbow(7))
>
>
>
> The plot itself gives me a y scale displaying ticks at 2, 5, 10, 20, 100, 200, 500. I would like to get a y scale where it would display ticks at every 4 marks, at 2, 20, 100 and 500.
>
>
>
> I tried ylim=c(2,20,100,500) but nothing happened. Actually I got an error.
ylim needs to be the extreme limits of the axis, i.e. a vector of length
2.
Suppress axis plotting and then draw your own:
interaction.plot(...., axes = FALSE)
axis(2, at = c(2,20,100,500))
E.g., using the example in ?interaction.plot
> with(ToothGrowth, interaction.plot(dose, supp, len, fixed=TRUE, axes = FALSE))
> axis(2, at = c(10, 20))
> axis(1)
> box()
Does that help?
G
>
>
>
> Could you help me?
>
>
>
> Thank you.
>
>
>
> Maria
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list