Getting crazy with "legend"

Hi, I found an odd problem with "legend". I get the right

    > labels/text but not the "small colour bars" associated to
    > them. There is something I must do wrong..

    > Here is a fake example:

    > Thanks for any input on this!

There are two problems with your example

    pa1 = hist(arange(1,100,1), bins=arange(0,100,10))
    pa2 = hist(arange(1,100,1), bins=arange(0,100,10))

matplotlib provides a "no plot" hist function in matplotlib.mlab. So
rather than calling the pylab hist (which plots) and then clearing the
figure with clf (you forgot the parentheses of clf, btw), call
matplotlib.mlab.hist which computes the histogram but doesn't plot.

    width = 5 # the width of the bars
    p1 = bar(pa1[1], pa1[0], width, color='r')
    p2 = bar(pa2[1]+width, pa2[0], width, color='y')

The above code is OK.

    legend([pa1[0], pa2[0]], ["$r_e/5$", "$r_e/2.5$"], shadow=True)

This is the second problem. pa1 and pa2 in your example are the
return values from pylab hist, which is (n, bins, patches). You need
to pass the patches returned by the bar command, eg p1[0], p2[0]

Here is the recommended way:

    from pylab import *
    import matplotlib.mlab # provides hist w/o plot

    n1, bins1 = matplotlib.mlab.hist(arange(1,100,1), bins=arange(0,100,10))
    n2, bins1 = matplotlib.mlab.hist(arange(1,100,1), bins=arange(0,100,10))

    width = 5 # the width of the bars
    p1 = bar(bins1, n1, width, color='r')
    p2 = bar(bins1+width, n2, width, color='y')

    legend([p1[0], p2[0]], ["$r_e/5$", "$r_e/2.5$"], shadow=True)

Should help!