Patch: correcting legend behavior for missing handles

Hi there, in the attachment, find a patch for the legend

    > to behave correctly when some of the handles are set to
    > None. (In which case the corresponding space is just left
    > empty.)

When would some of the handles be None? That looks like a bug to
me...

···

Without this patch, everything is first set up correctly,

    > but then the _update_positions routine shifts the items
    > in the legend box around incorrectly.

I'm probably using legends in an unusual way (you might call it "abusing"...):

In my plot, I have certain information refering to individual plot-lines.
These, I put regularly into the legend, together with a handle of the
corresponding line.

Other information refers to the whole figure, but should be visible in a
similar way as the regular legend information. The way I do this, is to place
it in additional legend entries without handle.

As an example: i have different datasets for different energies and different
bfields. One figure should now contain five plots of identical energy but
different bfield. The legend box would then p.e. contain one line "energy=2.3
eV" without handle, and five lines "bfield=?? T" with handles. In between, I
can even put one additional empty line to make everything more readable.

The current code handles this "abuse" nearly correct, except for the incorrect
rearrangement in _update_positions. My patch should not affect anyone who
uses the legend in the regular way, and for those who abuse the legend
intentionally or unintentionally, the patched version certainly behaves more
predictable.

···

On Tuesday 26 October 2004 19:52, John Hunter wrote:

    > Hi there, in the attachment, find a patch for the legend
    > to behave correctly when some of the handles are set to
    > None. (In which case the corresponding space is just left
    > empty.)

When would some of the handles be None? That looks like a bug to
me...

--
_________________________________________Norbert Nemec
         Bernhardstr. 2 ... D-93053 Regensburg
     Tel: 0941 - 2009638 ... Mobil: 0179 - 7475199
           eMail: <Norbert@...160...>