On May 14, 2010, at 9:59 AM, Justin Fincher wrote:

> I have two datasets that I would like to plot in a single figure.  The first
> plot is generated by a function that then takes a subset of the data.  (It
> is biological data so it is usually by chromosome e.g.
> function(data1,subset="chr8") ) Since not only are the chromosomes different
> sizes, but across different datasets there may be different numbers of
> points for a single chromosome, I do not know the coordinates on the x-axis
> prior to running the function.
> 
> I want the scale of the second plot to align to that of the first, but I
> don't know how to find the default xlim for the graph generated by the
> function.  Is there any way to access this information so I can then pass it
> to the plot() of the second plot?  Thanks!
> 
> - Fincher


The result of par("usr") will give you the actual limits of the x and y axes 
(plot region) once the first graphic is drawn to the device. See ?par for more 
information. Note that by default, R will extend the data ranges by 4% (see 
'xaxs' in ?par).

However, you are better off getting the common ?range of the relevant values in 
both subsets of data before plotting and then explicitly set the same x and y 
axis ranges in each plot by using the 'xlim' and 'ylim' arguments to plot().

HTH,

Marc Schwartz

______________________________________________
R-help@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.

Reply via email to