[R] Range difference of plot two arrays in one plot
Jeff Newmiller
jdnewmil at dcn.davis.CA.us
Fri Feb 1 18:51:27 CET 2013
One method is to follow correct usage of base graphics and only use the plot function once for each plot. To overlay, use a function like points or lines.
Another approach is to use lattice graphics or ggplot2 and give the data to higher-level plot routines that know how to plot multiple groups of data together.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
"Yuan, Rebecca" <rebecca.yuan at bankofamerica.com> wrote:
>Hello all,
>
>When I tried to plot the following two arrays in one figure with the
>following:
>
>x = c(0,0,0,10,20,30)
>y = c(40,50,60,70,80,90)
>plot(x, type='o', ylim=c(min(x),max(x)))
>par(new=T)
>plot(y, type='l', ylim=c(min(y),max(y)))
>
>Found that the first points and last points from those two arrays are
>overlapping together, but the value 30 is not equal to 90. How could I
>draw those two arrays in one plot with their real values shown in the
>plot? i.e., x is in the lower part of the plot and y is in the upper
>part of the plot.
>
>Thanks very much!
>
>Cheers,
>
>Rebecca
>
>
>
>----------------------------------------------------------------------
>This message, and any attachments, is for the intended
>r...{{dropped:5}}
>
>______________________________________________
>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