How to delete legend with matplotlib OO from a graph?

Hi list,

I'm using matplotlib oo to monitor figure.
I successfully add a legen with :
self.fig = Figure(figsize=(self.hSize,self.vSize), dpi=self.res)
self.a = self.fig.add_subplot(111)
self.a.legend(self.labels,loc='best')

How can i delete this legend?

Thanks a lot,
Philippe Collet

Hello Philippe,

philopensource@...32... schrieb:

Hi list,

I'm using matplotlib oo to monitor figure.
I successfully add a legen with :
self.fig = Figure(figsize=(self.hSize,self.vSize), dpi=self.res)
self.a = self.fig.add_subplot(111)
self.a.legend(self.labels,loc='best')

How can i delete this legend?

A quick glance at the corresponding source code (method 'legend' in 'axes.py') shows that the legend is set as axes.legend_.

To remove a legend, you therefore only need to do

self.a.legend_ = None

and redraw the figure.

Regards,

Niklas.