[R] Automatic adjustment of axis ranges

Marc Schwartz mschwartz at medanalytics.com
Thu Jul 18 05:03:46 CEST 2002


> -----Original Message-----
> From: owner-r-help at stat.math.ethz.ch
[mailto:owner-r-help at stat.math.ethz.ch] On
> Behalf Of Daniel Mastropietro
> Sent: Wednesday, July 17, 2002 7:13 PM
> To: R-help at stat.math.ethz.ch
> Subject: [R] Automatic adjustment of axis ranges
> 
> Hello,
> 
> I would like to know if it is possible to add new points to a given
plot
> and that the axis ranges be automatically adjusted so that all the new
> points are seen in the plot.
> For example, I am thinking of something like this:
> 
> plot(1:10,1:10);
> points(5:20,2*(5:20));	# This would change the x range to 0-20
and the y
> range to 0-40 so that all the new points are fitted in the graph.
> 
> Thanks
> Daniel Mastropietro

To the best of my knowledge, once a plot is drawn in the graphics
device, the plot region axis ranges are fixed.

You can certainly add new points, lines, etc. to an existing plot as you
are doing above, but within the existing axis ranges.

If you need to change the axis ranges themselves, I believe that you
actually have to re-draw the plot.

If you know what the minimum and maximum values of the existing and the
new data points are going to be, you can explicitly define the ranges
with the xlim and ylim arguments to the plot() function.  You can either
provide specific numbers or use the range() function to secure the min
and max values from the numeric vectors that you are using as source
data.

If someone has other ideas, I would certainly be interested in how this
could be done.

HTH.

Marc



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