[R] Automaticall adjust axis scales

R. Michael Weylandt michael.weylandt at gmail.com
Mon Mar 19 19:52:55 CET 2012


I don't believe this is possible in base graphics: you need to plan
your graphics ahead with something like plot(, ylim = range(x1, x2,
x3)). There's a pen-and-paper approach which means once something is
there, it's on the device permanently (unless you write over it).
Perhaps an interactive graphics package would allow it -- but I'll
happily be corrected (and informed) by others.

As a style thing, your use of c() is unnecessary and confusing.

identical(1:10, c(1:10))

Michael

On Mon, Mar 19, 2012 at 2:40 PM, Alaios <alaios at yahoo.com> wrote:
> Dear all,
>
> I have made a function that given a number of list elements plot them to the same window.
>
> The first element is plotted by using plot and all the rest are plotted under the
>
> same window by using lines.
>
> I have below a small and simple reproducible example.
>
>
> x1<-c(1:10)
> plot(x1)
>
> x2<-c(11:20)
> lines(x2)
>
> x3<-c(31:40)
> lines(x3)
>
>
>
>
> as you might notice
> the two consecutive lines fail to be plotted as the axis were formed by the first plot.
> Would it be possible after the last lines to change the axis to the minimum and the maximum of all data sets to be visible?
>
> Any idea how I can do that?
>
> I would like to thank you for your help
>
> B.R
> Alex
>
>        [[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.



More information about the R-help mailing list