On Thu, Jun 21, 2012 at 4:09 PM, Andre' Walker-Loud <walksl...@gmail.com>wrote:

> Hi All,
>
> Sometimes, instead of using data points with error bars, I instead use
> fill_between to create a little bar, with a band which I use alpha=.3 or so.
>
> I have tried unsuccessfully to find an easy way to create a legend label
> for this band - I am trying to have a similar band appear in my legend.
>
> I am not attached to fill_between if there is a similar way to create such
> a "little bar" to represent my data point.
>
>
> Thanks,
>
> Andre
> ----------------------------------------------------------
>
> Hi Andre,

Unfortunately, I think the preferred method is to create a proxy artist:

http://matplotlib.sourceforge.net/users/legend_guide.html#using-proxy-artist

Basically, you draw a fake patch with the same parameters as your fill (see
example below).

Hope that helps,
-Tony

# example from
http://comments.gmane.org/gmane.comp.python.matplotlib.general/29476
def fill_between(x, y1, y2=0, ax=None, **kwargs):
    """Plot filled region between `y1` and `y2`.

    This function works exactly the same as matplotlib's fill_between,
except
    that it also plots a proxy artist (specifically, a rectangle of 0 size)
    so that it can be added it appears on a legend.
    """
    ax = ax if ax is not None else plt.gca()
    ax.fill_between(x, y1, y2, **kwargs)
    p = plt.Rectangle((0, 0), 0, 0, **kwargs)
    ax.add_patch(p)
    return p
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to