Plotting vertical bars of arbitrary, non-uniform widths

John Hunter <jdhunter@...5...> wrote:

I think what you are looking for is the "bar" function --
http://matplotlib.sf.net/matplotlib.pylab.html#-bar. See
examples/barchart_demo.py.

Or do I misundertand what you are after..

You understood well, thank you. I was confused because at first, when I
looked at hist(), I saw that its argument 'bins' can be a sequence. From
that, I inferred that non-uniform widths were allowed for the bins.
After testing and reading the code, I understood this was wrong. Then, I
quickly looked at Axes.bar's docstring, since it was used in hist(), and
its beginning:

        BAR(left, height, width=0.8, bottom=0,
            color='b', yerr=None, xerr=None, ecolor='k', capsize=3)

        Make a bar plot with rectangles at

          left, left+width, 0, height

        left and height are Numeric arrays.

made me think that 'width' could only be a float, not an array.

So, bar() does what I need. There is still one somewhat weird thing,
however: barh() (as the barv() I wrote based on barh()) works with the
*centers* of the bars (y-coordinates for barh(), x-coordinates for
barv()) whereas bar() expects the *left* x-coordinates of the bars in
its first argument. This is not a drama, but a bit inconsistent.

Thanks.

···

--
Florent