using legend with fill

Hi,

    > I have produced a figure and used 'fill' to plot regions
    > in that figure. I wanted to place a legend for it, but
    > when I tried it only the labels appeared - no coloured
    > squares indicating the colours of the fills, as you get
    > in Matlab. Is it possible to do this? I noticed in one of
    > the example scripts that it works with a barchart. I
    > would like to use it in the same way, but with 'fill's.

In matplotlib/legend.py, on line 182, try replacing

            elif isinstance(handle, Rectangle):

with

            elif isinstance(handle, Patch):

and try again. If it fails, please send in an example script that
exposes the problem, but let me know in any case. Note this solution
will still draw a little rectangle in the legend rather than a
miniature polygon the same shape as the fill one, but it will
otherwise have the same properties (eg facecolor). What does matlab do?

Cheers,
JDH