new legend interface and WXAgg interactive mode

Hello,

I couldn’t find this in the API changes, but when I upgraded to the latest matplotlib 0.98.2, I found (after much hair pulling) that

gca().plot([1,2,1], label=’_anything’)

will produce a plot and

gca().legend()

will not display the specified label. I had been using filenames starting with underscores before and nolabel to keep from showing a legend entry. Is this a bug or has the philosophy changed to eliminate anything starting with an underscore from the legend? I think if anything None or maybe “” should be used for empty labels.

Second, I am using interactive mode and WXAgg in windows. So my startup script does this:

import matplotlib as _mpl

_mpl.use(‘WXAgg’)

import pylab as _p

_p.ion()

Before, when I would then type

gca().plot([1,2,1])

a plot would appear showing the data. Now I just get a blank figure, and I have to type _p.draw() to see the data. I’m also not sure if this is a bug or a philosophy change, but I did find the old interactive mode was useful.

Cheers,
Jack

Hello,
I couldn't find this in the API changes, but when I upgraded to the latest
matplotlib 0.98.2, I found (after much hair pulling) that
gca().plot([1,2,1], label='_anything')
will produce a plot and
gca().legend()
will not display the specified label. I had been using filenames starting
with underscores before and _nolabel_ to keep from showing a legend entry.
Is this a bug or has the philosophy changed to eliminate anything starting
with an underscore from the legend? I think if anything None or maybe ""
should be used for empty labels.

I had to check the code to see why this was so, but we do exclude
everything that starts with an underscore, even though we only
document the '_nolegend_'. I suspect that this change was designed to
support the autolabeling of lines when added without a label. In
Axes.add_line:

        if not line.get_label():
            line.set_label('_line%d'%len(self.lines))

but I don't recall why we added this bit of functionality. I'm not
sure at this point if we should change the doc to reflect reality or
change reality to reflect the doc, so perhaps someone using the
auto-labeled line feature should chime in here.

Second, I am using interactive mode and WXAgg in windows. So my startup
script does this:
import matplotlib as _mpl
_mpl.use('WXAgg')
import pylab as _p
_p.ion()
Before, when I would then type
gca().plot([1,2,1])

I would not expect a draw here, since draw only happens on pylab
commands. Eg _p.plot should trigger a draw, but not gca().plot
because the latter is an axes method. I don't really know why it
would have worked before, if it did. I would be pretty surprised if
it did, actually.

JDH

···

On Tue, Sep 16, 2008 at 2:14 PM, Jack Sankey <jack.sankey@...149...> wrote:

John Hunter schrieb:

Second, I am using interactive mode and WXAgg in windows. So my startup
script does this:
import matplotlib as _mpl
_mpl.use('WXAgg')
import pylab as _p
_p.ion()
Before, when I would then type
gca().plot([1,2,1])
    
I would not expect a draw here, since draw only happens on pylab
commands. Eg _p.plot should trigger a draw, but not gca().plot
because the latter is an axes method. I don't really know why it
would have worked before, if it did. I would be pretty surprised if
it did, actually.
  

Older versions of the wx and wxagg backend indeed unnecessarily rerendered the figure (triggered a draw) very often - with every paint event. This has been fixed.

Gregor