Hi -- I have searched the documentation and archives on graphing capabilities in R for the past couple of hours, but I haven't been able to find anything directly related to my problem. I want to create a plot with several lines displayed on it. I want each line to be displayed in a different color, so it seems the only way to do this is to create a plot and then use the lines() function. However, once i create the original plot, when I add new lines to the plot, the axes range stays the same, and the new lines often extend beyond the range of the original axes, cutting off the data of the added lines. Is there any way to force the plot to resize it's axes range when new lines are added, or is there some other optional way of implementing this? Thanks. DISCLAIMER: This e-mail message and any attachments are inte...{{dropped}}
In traditional, or "base" graphics, see "matplot", which does exactly what you describe. You can also look at lattice graphics, which will give you flexibility to plot in a single panel or multiple panels. Hope this helps, Matt Wiener -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Hikel, Jerry Sent: Tuesday, May 24, 2005 4:41 PM To: R-help at stat.math.ethz.ch Subject: [R] Plot range resizing when adding additiona lines Hi -- I have searched the documentation and archives on graphing capabilities in R for the past couple of hours, but I haven't been able to find anything directly related to my problem. I want to create a plot with several lines displayed on it. I want each line to be displayed in a different color, so it seems the only way to do this is to create a plot and then use the lines() function. However, once i create the original plot, when I add new lines to the plot, the axes range stays the same, and the new lines often extend beyond the range of the original axes, cutting off the data of the added lines. Is there any way to force the plot to resize it's axes range when new lines are added, or is there some other optional way of implementing this? Thanks. DISCLAIMER: This e-mail message and any attachments are inte...{{dropped}} ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Hikel, Jerry wrote:> Hi -- I have searched the documentation and archives on graphing > capabilities in R for the past couple of hours, but I haven't been able > to find anything directly related to my problem. > > I want to create a plot with several lines displayed on it. I want each > line to be displayed in a different color, so it seems the only way to > do this is to create a plot and then use the lines() function. However, > once i create the original plot, when I add new lines to the plot, the > axes range stays the same, and the new lines often extend beyond the > range of the original axes, cutting off the data of the added lines. > > Is there any way to force the plot to resize it's axes range when new > lines are added, or is there some other optional way of implementing > this? Thanks. > > > DISCLAIMER: This e-mail message and any attachments are inte...{{dropped}} > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >You can check the range of all items to plot and take the minimum and maximum value across all items. Then draw the plot with the axis range explicitely set to 'minimum'-'maximum'! That is assuming you know the items you are drawing before hand. Sander. -- -------------------------------------------- Dr Sander P. Oom Animal, Plant and Environmental Sciences, University of the Witwatersrand Private Bag 3, Wits 2050, South Africa Tel (work) +27 (0)11 717 64 04 Tel (home) +27 (0)18 297 44 51 Fax +27 (0)18 299 24 64 Email sander at oomvanlieshout.net Web www.oomvanlieshout.net/sander
That's what i wound up doing -- i am totally new to R, so i wasn't sure if there were an easy way of getting the min and max values of a data frame, but i tried that and it worked out well. Thanks. -----Original Message----- From: Sander Oom [mailto:slist at oomvanlieshout.net] Sent: Tuesday, May 24, 2005 5:04 PM To: Hikel, Jerry Cc: r-help at stat.math.ethz.ch Subject: Re: [R] Plot range resizing when adding additiona lines Hikel, Jerry wrote:> Hi -- I have searched the documentation and archives on graphing > capabilities in R for the past couple of hours, but I haven't been > able to find anything directly related to my problem. > > I want to create a plot with several lines displayed on it. I want > each line to be displayed in a different color, so it seems the only > way to do this is to create a plot and then use the lines() function. > However, once i create the original plot, when I add new lines to the > plot, the axes range stays the same, and the new lines often extend > beyond the range of the original axes, cutting off the data of theadded lines.> > Is there any way to force the plot to resize it's axes range when new > lines are added, or is there some other optional way of implementing > this? Thanks. > > > DISCLAIMER: This e-mail message and any attachments are > inte...{{dropped}} > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >You can check the range of all items to plot and take the minimum and maximum value across all items. Then draw the plot with the axis range explicitely set to 'minimum'-'maximum'! That is assuming you know the items you are drawing before hand. Sander. -- -------------------------------------------- Dr Sander P. Oom Animal, Plant and Environmental Sciences, University of the Witwatersrand Private Bag 3, Wits 2050, South Africa Tel (work) +27 (0)11 717 64 04 Tel (home) +27 (0)18 297 44 51 Fax +27 (0)18 299 24 64 Email sander at oomvanlieshout.net Web www.oomvanlieshout.net/sander --------------------------------------------- DISCLAIMER: This e-mail message and any attachments are inte...{{dropped}}