[Rd] pairs, par

Tony Plate tplate at acm.org
Mon Oct 29 17:56:49 CET 2007


I would look into the code for pairs().  Among other things, it sets and 
restores par(mfrow=...).  I suspect this is the relevant issue, not the 
use of pairs().  I would try to figure out what state a graphics device 
is in after resetting par("mfrow").  When I try the following (R 2.6.0 
patched, under Windows), I see a line on the plot, but not in a place 
that corresponds to the axis that were drawn by the 'plot()' command:

 > par(mfrow=c(2,2))
 > plot(1:2)
 > par(mfrow=c(1,1))
 > lines(1:2,1:2)
 >

(and if you want to be able to set up a new coordinate system on the 
plotting device to draw on top of the plot left by pairs(), look at 
par("new") & something like plot(0:1, type='n', axes=F, xlab=""))

hope this helps,

Tony Plate

Oliver Soong wrote:
> Hi,
>
> I posted over at R-help, and didn't get a response, but perhaps that
> was the wrong forum for this question.  I'm having some confusion over
> the coordinate system after using pairs.  I'm not interested in the
> content of the actual pairs plot, although the number of pairs seems
> to matter a bit.  I'm purely interested in knowing where subsequent
> points will be plotted on the device.  However, after using pairs, the
> par information (omd, fig, plt, and usr) don't reflect what points
> does.  For example:
>
> pairs(iris[1:5])
> par(xpd = NA)
> points(0 - 0.01 * 1:100, 0 - 0.01 * 1:100)
> points(0 - 0.01 * 1:100, 1 + 0.01 * 1:100)
> points(1 + 0.01 * 1:100, 0 - 0.01 * 1:100)
> points(1 + 0.01 * 1:100, 1 + 0.01 * 1:100)
> par(c("omd", "fig", "plt", "usr"))
>
> The resulting plot shows that the corners of the are approximately
> 0.05 user coordinate units from the boundaries of the plot region.
> According to par, though, there is a margin around the plotting region
> that is clearly not symmetric and does not correspond to around 0.05
> units.
>
> If we use pairs(iris[1:2]) and repeat the rest, the corners are now
> 0.02 user coordinate units.  par provides the same information as
> before.
>
> So:
> 1. How do I figure out where coordinates I give to points will display
> on the figure?
> 2. More generally (for my own understanding), why does the par
> information not do what I expect?  Do I have some fundamental
> misunderstanding of the arrangement of plotting, figure, display, and
> margin regions within the device?  Is there a bug in pairs and/or par?
>
> I'm using R 2.5.1, and this behavior occurs on a fresh R console.
>
> Thanks!
>
> Oliver
>
>
>



More information about the R-devel mailing list