Documentation on AGG filters


Is there any documentation available on how to write and use AGG filters in matplotlib ? The only information I could gather comes from the rather obscure example in

This is a very powerful feature and I ended up adapting one of these demo filters to achieve what I wanted (a glossy effect on pie charts), but it took me quite a lot time to figure out what was going on through trial and error, and I can't shake away the feeling that I am not really sure of what I actually did.

Anyone knows of a comprehensive doc or tutorial on that subject ?


Matthieu Huin

Unfortunately there is no such things as far as I know.

The agg_filter itself has relatively simple api (from the
documentation of backend_agg.stop_filter).

        Save the plot in the current canvas as a image and apply
        the *post_processing* function.

           def post_processing(image, dpi):
             # ny, nx, depth = image.shape
             # image (numpy array) has RGBA channels and has a depth of 4.
             # create a new_image (numpy array of 4 channels, size can be
             # different). The resulting image may have offsets from
             # lower-left corner of the original image
             return new_image, offset_x, offset_y

        The saved renderer is restored and the returned image from
        post_processing is plotted (using draw_image) on it.

So, any callable object with above api can be used as a filter. And
the classes in the above example describes just one way to create such

The agg_filter functionality is a very experimental feature. While I
contributed the example code, I myself rarely use this feature. And
I'm afraid that I may not be able to find enough time to maintain
and/or improve the code.




On Wed, Oct 27, 2010 at 10:36 PM, Matthieu Huin <matthieu.huin@...3335...> wrote:

Anyone knows of a comprehensive doc or tutorial on that subject ?