Paul Lemmens
2007-Jul-04 07:48 UTC
[R] Adding data to existing plot with new=TRUE does not appear to work
Dear all, I am trying to shove a number of cmdscale() results into a single plot (k=1 so I'm trying to get multiple columns in the plot). From ?par I learned that I can/should set new=TRUE in either par() or the plot function itself. However with the following reduced code, I get only a plot with a column of data points with x==2. plot(1,10, xlim=range(0,3), ylim=range(0,10), type='n') aa <- rep(1,10) bb <- 1:10 plot(aa,bb, xlim=range(0,3), ylim=range(0,10), new=TRUE) aa <- rep(2,10) plot(aa,bb, xlim=range(0,3), ylim=range(0,10), new=TRUE) Also, when I insert a op <- par(new=TRUE) either before or immediately after the first plot statement (the type='n' one) in the above code fragment, the resulting graph still only shows one column of data. Have I misinterpreted the instructions or the functionality of new=TRUE? Thank you, Paul Lemmens
Petr PIKAL
2007-Jul-04 09:22 UTC
[R] Odp: Adding data to existing plot with new=TRUE does not appear to work
Hi if you change your code plot(1,10, xlim=range(0,3), ylim=range(0,10), type='n') aa <- rep(1,10) bb <- 1:10 plot(aa,bb, xlim=range(0,3), ylim=range(0,10), new=TRUE) aa <- rep(2,10) par(new=T) plot(aa,bb, xlim=range(0,3), ylim=range(0,10), new=TRUE) you will get both columns plotted. However you can get similar result with using points plot(1,10, xlim=range(0,3), ylim=range(0,10), type='n') aa <- rep(1,10) bb <- 1:10 points(aa,bb) aa <- rep(2,10) points(aa,bb) Regards Petr petr.pikal at precheza.cz r-help-bounces at stat.math.ethz.ch napsal dne 04.07.2007 09:48:15:> Dear all, > > I am trying to shove a number of cmdscale() results into a single plot > (k=1 so I'm trying to get multiple columns in the plot). From ?par I > learned that I can/should set new=TRUE in either par() or the plot > function itself. However with the following reduced code, I get only a > plot with a column of data points with x==2. > > plot(1,10, xlim=range(0,3), ylim=range(0,10), type='n') > aa <- rep(1,10) > bb <- 1:10 > plot(aa,bb, xlim=range(0,3), ylim=range(0,10), new=TRUE) > aa <- rep(2,10) > plot(aa,bb, xlim=range(0,3), ylim=range(0,10), new=TRUE) > > Also, when I insert a op <- par(new=TRUE) either before or immediately > after the first plot statement (the type='n' one) in the above code > fragment, the resulting graph still only shows one column of data. > > Have I misinterpreted the instructions or the functionality of new=TRUE? > > Thank you, > Paul Lemmens > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
Paul Lemmens
2007-Jul-04 11:00 UTC
[R] Adding data to existing plot with new=TRUE does not appear to work
Hi Petr, On 7/4/07, Petr PIKAL <petr.pikal at precheza.cz> wrote:> par(new=T) > plot(aa,bb, xlim=range(0,3), ylim=range(0,10), new=TRUE) >So I need to activate the par(new=T) really just ahead of time when I need it, not as sort of a general clause at the beginning of my script?> > However you can get similar result with using points >Yes I new that, but I wanted to try and go without an if() for deciding between the first and consecutive columns. Thnx for helping out! Paul Lemmens
Possibly Parallel Threads
- subset(..., drop=TRUE) doesn't seem to work.
- Numbers that look equal, should be equal, but if() doesn't see as equal (repost with code included)
- Accessing columns in data.frame using formula
- Dynamic string as element name in a list
- add spline to longitudinal data - preferably similar to SAS's 'I=SM50S' routine