distorted patches

I've been rewriting the Arrow class in patches.py to improve

    > the look of quiver plots and am getting generally good
    > results. The problems with current quiver plots are that
    > arrows representing very small values are scaled along their
    > length but not in width and also that arrowheads are not of
    > a constant size. I have addressed both of these problems and
    > getting results much more like Matlab quiver plots
    > now. However, now that I am scaling arrow patches down to
    > very small sizes, I see weird shaped arrows at some zoom
    > levels but when I zoom in close enough to see the shape
    > properly they look nicely formed. Is there a known problem,
    > perhaps with Agg doing some fancy truncation in order to
    > achieve good speed, where patches are distorted if their
    > vertices are very close together at a particular
    > magnification? I can provide code and graphic examples if it
    > would help.

My guess is that this has something to do with subpixel rendering, and
it has cropped up in a number of circumstances. Unfortunately, I
don't know of an easy answer. If you tell agg to draw a line from 0,0
to 1,1, the line will look different than a line from .5,.5 to 1.5,1.5


One way to confirm that this is your problem is to turn antialiasing


but I just noticed that the agg draw_polygon method does not respect
the aa setting, so I just committed changes to svn to fix this. Do
you have access to svn?

With svn in the example below, the green polygon should look more
jaggy than the yellow one. My guess is that this weirdness for small
arrows will go away with antialiasing off, but then you will have
crappy, aliased arrows. Not sure what the right answer is...

from matplotlib.patches import RegularPolygon
from pylab import figure, show

p1 = RegularPolygon((1,1), 5, antialiased=True, facecolor='yellow', linewidth=5)
p2 = RegularPolygon((0,0), 5, antialiased=False, facecolor='green', linewidth=5, alpha=0.5)

fig = figure()
ax = fig.add_subplot(111, xlim=(-6,6), ylim=(-6,6), autoscale_on=False)


Hi John,
I'll have a look at this over the weekend.
From the link and example you provided I'm not yet sure that subpixel rendering is the problem, but it could well be - What I'm getting is the vertices displaced away from the expected position by quite a way, but I'll see if the patch you made is at the Python level, in which case I can try it easily, or if at the C level, it may be time to try my Ubuntu installation out and finally learn to build from source.