[R] Annoying bug (?) in package cairoDevice
Josh Gilbert
jgilbert.r at gmail.com
Tue Apr 29 22:26:39 CEST 2008
I apologize for sending this twice, I didn't realize that gmail
helpfully defaulted to rich formatting.
For some reason, Cairo_png puts a box around a figure when you call
plot.new. It looks like box was called with black and a transparent
background. Example:
> library(cairoDevice)
> Cairo_png('cairo.png')
> plot.new()
> dev.off()
null device
1
The boarder is narrow, so it's hard to see with a stand-alone image
viewer. If you paste the png onto a white background it's quite clear.
Admittedly, the default for par("bg") is transparent, par("bty") is
"o" and par("col") is black. However, this behavior is not consistent
with other devices (such as png in grDevices even if I set
par(bg="white")). Also, Cairo_png draws the box even when
par(bty="n").
I just tested this on Debian with version 2.6 of cairoDevice. I've
also observed this behavior on Windows and it's not a new problem.
The only workaround I've found is to call
> Cairo_png()
> par(col="white")
> setHook("plot.new", function() par(col="black"))
> plot(...)
As far as I'm concerned, this is a serious bug, it's a real problem
when creating figures for publication. I'd like confirmation that this
is, in fact, a bug as I haven't seen much documentation for standards
for devices. I suspect that it's a shallow bug, but I've never seen
the code for plot.new nor do_Cairo so my suspicion may be more hope
than insight.
Josh Gilbert
Statistical Researcher
Broad Institute
Chemical Biology Program
More information about the R-help
mailing list