black and hatched legend handle

I'm trying to make a legend handle that is half black and half hatched. I've
tried ...

...
rpos1 = ax.bar(ind, pos1, width, color='k', label='+1')
rneg1 = ax.bar(ind, neg1, width, color='w', hatch='///', label='-1')

rpos2 = ax.bar(ind, pos2, width, color='w', label='+2')
rneg2 = ax.bar(ind, neg2, width, color='w', label='-2')

handles, labels = ax.get_legend_handles_labels()
ax.legend( ((handles[0], handles[1]), handles[2]) , ('one', 'two') )
...

The first handles--handles[0] and handles[1]--are combined but not side by
side: the hatched rectangle is placed over the top of the black rectangle so
the handle looks like it is just hatched. How might I create this mixed
handle?

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/black-and-hatched-legend-handle-tp40979.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

You need to create a new handler. I guess the code below is close to what you want. I hope this helps.

http://nbviewer.ipython.org/5495680

Regards,

-JJ

···

On Wed, May 1, 2013 at 5:24 AM, mgurling <magurling@…287…> wrote:

I’m trying to make a legend handle that is half black and half hatched. I’ve

tried …

rpos1 = ax.bar(ind, pos1, width, color=‘k’, label=‘+1’)

rneg1 = ax.bar(ind, neg1, width, color=‘w’, hatch=‘///’, label=‘-1’)

rpos2 = ax.bar(ind, pos2, width, color=‘w’, label=‘+2’)

rneg2 = ax.bar(ind, neg2, width, color=‘w’, label=‘-2’)

handles, labels = ax.get_legend_handles_labels()

ax.legend( ((handles[0], handles[1]), handles[2]) , (‘one’, ‘two’) )

The first handles–handles[0] and handles[1]–are combined but not side by

side: the hatched rectangle is placed over the top of the black rectangle so

the handle looks like it is just hatched. How might I create this mixed

handle?

View this message in context: http://matplotlib.1069221.n5.nabble.com/black-and-hatched-legend-handle-tp40979.html

Sent from the matplotlib - users mailing list archive at Nabble.com.


Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET

Get 100% visibility into your production application - at no cost.

Code-level diagnostics for performance bottlenecks with <2% overhead

Download for free and get started troubleshooting in minutes.

http://p.sf.net/sfu/appdyn_d2d_ap1


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

That looks like exactly what I am looking for. Thanks JJ.

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/black-and-hatched-legend-handle-tp40979p41247.html
Sent from the matplotlib - users mailing list archive at Nabble.com.