legend

the bug:

    > I tried:

    > plot([1,2],[4,5],'g^',markersize=4,label='1')
    > errorbar([1,4],[6,7],[1,1],fmt='bh',markersize=4,label='4')
    > #plot([3,4],[6,7])
    > legend()
    > show()

    > and there are a problem with errorbar and the label and
    > the legend. Different line appeard and at the end we have
    > only the good symbols)

I don't consider this a bug but maybe you can convince me :-). Legend
tries to be helpful but not omniscient. If you have many lines and
only want to include some of them in the legend, just use the explicit
legend(lines, labels) form

    from matplotlib.matlab import *
    l1, = plot([1,2],[4,5],'g^',markersize=4)
    l2, errlines = errorbar([1,4],[6,7],[1,1],fmt='bh',markersize=4)

    plot([3,4],[6,7])

    legend((l1, l2), ('1', '4'))

    show()

Your suggestion that the legend ignore lines with empty labels appears
reasonable at first glance, but as Norbert will tell you, some people
use the fact that matplotlib legends include lines with empty labels
to their advantage when laying out legends.

So in this case there is a way to get matplotlib to make the legend
you want, and if legend tries to get too smart about guessing what you
want it will get in the way of power users who don't what matplotlib
guessing what they are trying to do.

    > 2)

    > I add the line: plot([3,4],[6,7]) only to show you that
    > even if the plot command doesn't have a label the legend
    > give a place for it. I think at two solution to solve this
    > (perhaps it's already implemented and I didn't find...):

    > - by default if there are some label with the plot command
    > the plot command without are not take in count to create
    > the legend

    > - add something like: label=None to indicate the the user
    > don't want this line in the legend.

This could work. Currently the default label is '', which as I said
is a perfectly legitimate label in some cases. We could use None as a
hint to legend. It would increase the coding burden somewhat, since
we'd always have to check for None before performing string ops on the
legend. I'm amenable to this approach. Anyone else have input here?

    > Thanks again to have found and correct all this bug so
    > fast, I'm very impressed :slight_smile:

Thanks!
JDH