Feature request: additional arguments of hist()

If possible, I think it is nice for matplotlib to be able to

    > plot histograms by not only bars but also lines. My meaning of
    > "bar histogram plotting" is like the bottom-left plot in
    > http://jas.freehep.org/images/screenshots/gui2.gif and "line
    > histogram plotting" is like the others. There are two reasons.

If I understand you correctly, and from looking at the images you
linked to, all you need to do is set the edge and face properties of
the bars to the same color. The default edge color is black and the
default face color is blue, so if you want a solid histogram do

    from matplotlib.matlab import *

    mu, sigma = 100, 15
    x = mu + sigma*randn(10000)

    n, bins, patches = hist(x, 200, normed=1)
    set(patches, 'edgecolor', 'b')

Is this what you mean?

    > Off course, the bar histogram plotting is more smart in one
    > case, but in another case the line is better. In addition, the
    > support of both bar and line histogram plotting will matplotlib
    > to be able to have more plotting features that the colors of
    > line and filled area can be specified separately by the user.

The axes function 'vlines' plots vertical lines. See the

John Hunter

Thanks for your quick reply.

Is this what you mean?

More precisely, what I mean is like the top-left plot in http://www.slac.stanford.edu/grp/ek/hippodraw/canvaswindow.png

If I understand bar() (then hist()) functionalities correctly, it may be unable to create such a plot currently without using plot().

from matplotlib.matlab import *
bins = [0, 1, 2, 3]
vals = [3, 4, 5]
x = [bins[0]]
y = [0]
for i in range(len(bins) - 1):
    x.append(bins[i + 1])
    x.append(bins[i + 1])
    y.append(vals[i + 1])
plot(x, y)


On 2003.12.16, at 20:47 Japan, John Hunter wrote: