[R-SIG-Mac] Quartz graphics corruption

Simon Urbanek simon.urbanek at r-project.org
Fri Nov 16 20:19:46 CET 2007


On Nov 16, 2007, at 1:28 PM, Daschbach, John L wrote:

>
> A problem with saving graphics persists through many iterations of  
> the R
> gui.  I brought this up some time ago but it remains a troubling  
> issue.
> Often, when saving quartz graphics as PDF the graphic is printed  
> with other
> screen contents.  Often these are part of the contents of the R  
> console, but
> upside down.  With the problem earlier it seemed that saving from a  
> print
> dialog instead of quartz.save(), but currently it is common both  
> places.
>
> Also quite troubling is the printed figure is sometimes missing  
> elements.
> In the attached figure both problems are evident.  In the one screen  
> quartz
> window from which this was saved as pdf from a print dialog there is  
> a point
> at 400 K in the Peak Frequency data, but it is missing in plot.   
> Also note
> the print through from the console.
>
> For this I moved the console off screen so it physically did not  
> overlap the
> graphics window.
>
> If there is a work around I would like to know about it.


The problem appears to have something to do with the interaction of  
the console (i.e. when there is something being printed) with Quartz.

I have found two work arounds that worked for me:
1) issue quartz.save(..) twice. The second output is usually ok.
2) use a function to generate and save the graphics.

The following is just a hypothesis. The key (AFAICS) is that when you  
type quartz.save... and hit <Enter>, the console is being updated (new- 
line) at the same time as the graphics gets plotted which results in  
the corruption (why, that's still a mystery as the corruption does not  
happen on-screen). By issuing two quartz.save commands the second one  
is likely to run after the console was updated, so it doesn't get  
corrupted.
Analogously, by using a separate function to both plot and save the  
graphics, the saving will occur after the console was updated.

R-devel (2.7.0 to-be) features a completely new, re-written Quartz  
device that doesn't suffer from this effect, because it uses Quartz  
Extreme instead of Cocoa.

Cheers,
Simon



More information about the R-SIG-Mac mailing list