Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

[R] Plot zooming i.e. changing ylim according to xlim

Henrik Andersson

2005-07-26

Replies:

Dear R-gurus,

I would like to zoom in a plot, e.g. I select a region on the x-axis and
then I would like the ranges on the y-axis to change accordingly.

Is it possible to do this with existing functions, or do I have to
invent some data selection before plotting?

See below a short example, where I select ylim with trial and error,
which I want to avoid.

Cheers, Henrik Andersson
--------------------------------------------------------------------
## Example -- in reality more numbers, no function
x <- seq(0,20)
y <- exp(-x)

plot(y~x,type='l')

## Zoom in the end, to see what's happenning

plot(y~x,type='l',xlim=c(19,20))

## Try other ylim

plot(y~x,type='l',xlim=c(19,20),ylim=c(0,1))

## Not enough

plot(y~x,type='l',xlim=c(19,20),ylim=c(0,1E-8))

## Better
---------------------------------------------
Henrik Andersson
Netherlands Institute of Ecology -
Centre for Estuarine and Marine Ecology
P.O. Box 140
4400 AC Yerseke
Phone: +31 113 577473
h.andersson@(protected)
http://www.nioo.knaw.nl/ppages/handersson

______________________________________________
R-help@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
©2008 r-help.com - Jax Systems, LLC, U.S.A.