[Rd] Clipping using par(plt=..., xpd=FALSE) inconsistencies
Greg.Snow at imail.org
Fri Feb 22 20:09:03 CET 2008
Here is a demonstration of behaviour that is probably an optimization by
someone far smarter than me that did not anticipate anyone wanting to do
this, but for my purposes it looks more like a bug than a feature.
I have tested this with R2.6.2 on Windows, no additional packages loaded
(beyond the default), I have tested using the default graphics object,
pdf, jpeg, and cairoDevice (ok I loaded a package for that) and all show
the same behavior.
Run the following set of commands:
x <- rnorm(1000)
tmp <- par('plt')
tmp2 <- tmp
tmp2 <- tmp2 + 0.3
par(xpd = FALSE, plt=tmp2)
hist(x, col='red', add=TRUE)
tmp3 <- tmp
tmp3 <- tmp3 - 0.3
hist(x, col='blue', add=TRUE)
This gives me the plot that I want and expect (a histogram with the left
section red, the middle white/background, and the right blue).
Now comment out or delete the 2 box commands and rerun everything. The
clipping does not happen this time and the final result is a full blue
Is this a bug? Feature? Something else?
Does anyone have a better work around than drawing transparent boxes?
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
greg.snow at imail.org
More information about the R-devel