[R] plotting with same axes

Marc Schwartz (via MN) mschwartz at mn.rr.com
Mon Aug 22 19:11:43 CEST 2005


On Mon, 2005-08-22 at 12:58 -0400, sms13+ at pitt.edu wrote:
> I have used the 'par' command to 
> overlay one plot on another.  But how 
> do I overlay it with the x-values 
> plotted at the same points on the 
> x-axis?
> 
> Thank you,
> Steven

The specific answer depends to an extent on the graphics you are
plotting and whether there is a need to actually use par("new").

In some cases there is an 'add = TRUE' option to plotting functions that
allows for this. 

In others, you can create the initial plot and then use lines(),
points() or the like to simply add further plotting components to the
existing plot.

If all else fails and you need to use par("new"), then you will want to
explicitly define the x and y axes to the same ranges by using the same
'xlim' and 'ylim' arguments in _both_ plotting functions. 

A reproducible example of what it is you are doing would enable us to
give you more specific guidance, if the above is not helpful.

HTH,

Marc Schwartz




More information about the R-help mailing list