[R-SIG-Mac] problems with the png(type = quartz) device

Simon Urbanek simon.urbanek at r-project.org
Tue Jan 12 17:51:07 CET 2010


On Jan 12, 2010, at 8:50 , Kasper Daniel Hansen wrote:

> Steffen Neuman has provided the following reproducible example
>
> for (subtype in c("cairo", "Xlib", "quartz")) {
> png(filename=paste("test",subtype,"plot%003d.png", sep="_"),
>    width = 640, height = 480, type=subtype)
> for (i in c(1,2,3)) {
>  plot(0,0, type="n", main=i,
>       xlim=c(-1 + 0.1*i, +1 + 0.1*i),
>       ylim=c(-1 + 0.1*i, +1 + 0.1*i),
>       xlab="xlab",ylab="ylab")
>  points(0.1*i, 0.1*i , col=i)
>  Sys.sleep(1)
> }
> dev.off()
> }
>
> which shows that there is a clear problem with png(type =  
> "quartz").  I am even ready to mention the dreaded "b"-word :)
>

It's clearly a bug in multi-page bitmap output. Thanks, it is fixed now.


> As an aside I find the difference between cairo and Xlib a bit  
> strange: in the cairo device you can clearly see a difference  
> between the box around the plot and where the x-axis / y-axis has  
> been plotted.  This might be a rendering issue, but personally I  
> find it less aesthetically pleasing.

It depends a lot on your pixel size - in general it is not very  
pleasing when you use line widths that are narrower than the pixels of  
your bitmap output (Xlib just ignores it and always uses at least a  
pixel regardless since it  does not support subpixel rendering).  
Therefore you may want to adjust the resolution (dpi) and/or pixel  
size for your output. Alternatively you can disable anti-aliasing but  
the output is even more horrible (as the Xlib rendering shows). Quartz  
does pixel-snapping for rectangles so if your line width is close to a  
pixel it works well.

Cheers,
Simon



More information about the R-SIG-Mac mailing list