Skip to content

finding the plot limits generated by default

5 messages · Justin Fincher, Marc Schwartz

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

            
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
#
Justin,

Try something like this:

par(mfrow = c(2, 1))

drawGffPlots2(data1, data2, trackingDye = TRUE,
              slice = "chr13", newDev = 0)

plot(densities_subset$V4, densities_subset$V6, type = "h", 
        xlim = par("usr")[1:2], 
        xaxs = "i",
        xlab = "Position", ylab = "Gene Density")


Using 'xaxs = "i"' in the second call to plot() should fix the x axis range at the exact values passed for 'xlim'.


HTH,

Marc
On May 14, 2010, at 11:09 AM, Justin Fincher wrote: