Ken,

On Feb 13, 2006, at 7:08 PM, Ken Knoblauch wrote:

> About a year ago, I noticed that the image() function generated  
> fine grid lines in graphics when using the quartz() device but not  
> x11() and that these lines could be found in the pdf() generated  
> images when viewed  in some but not all pdf viewers.

This effect comes from the combination of anti-aliasing and sub-pixel  
rendering. Although those techniques represent objects more precisely  
and in an aesthetically more pleasing manner, they do not guarantee  
that two adjacent filled regions mesh seamlessly at sub-pixel level  
which is what you see at thin lines in the image plot.

There are basically two ways to fix this: plot overlaying rectangles  
or don't use sub-pixel rendering. Overlaying will work only if it is  
implemented directly in the image implementation, otherwise the plot  
would bleed over its axes. The other possibility is to not use sub- 
pixel rendering. In order to enforce pixel-aligned rectangles you can  
apply this patch:

Index: Quartz/QuartzDevice.m
===================================================================
--- Quartz/QuartzDevice.m       (revision 2298)
+++ Quartz/QuartzDevice.m       (working copy)
@@ -569,7 +572,7 @@
         QuartzDesc *xd = (QuartzDesc*)dd->deviceSpecific;
         NSBezierPath *rPath = [NSBezierPath bezierPath];
-       [rPath appendBezierPathWithRect:NSMakeRect(x0,y0,x1-x0,y1-y0)];
+       [rPath appendBezierPathWithRect:NSMakeRect(round(x0),round 
(y0),round(x1)-round(x0),round(y1)-round(y0))];
                 [xd->DevView lockFocus];
         NSRectClip(ClipArea);

This will make sure that rectangles are aligned and there will be no  
gap if the same real values are used. The drawback is that other  
objects will not exactly match the position of the rectangles  
anymore. This will be noticeable especially in smaller plots.  
However, this solution doesn't affect PDF output unless created with  
quartz.save.

Best,
Simon



	[[alternative HTML version deleted]]

