legend for bar charts?

is it possible to use matplotlib’s legend() for a bar chart? I am
plotting a number of bars with different colors on the same axes and I
would like to label each color.

legend () seems to want to label every single bar on my bar chart.

Thanks in advance.

yes, see

http://matplotlib.sf.net/examples/barchart_demo.py

In a nutshell, bar returns a list of rectangle objects, and you need
to pass a proxy element of this list (eg the first element) to the
legend command.

JDH

···

On Feb 7, 2008 8:21 AM, Reckoner <reckoner@...287...> wrote:

is it possible to use matplotlib's legend() for a bar chart? I am plotting
a number of bars with different colors on the same axes and I would like to
label each color.

legend () seems to want to label every single bar on my bar chart.