Clearing the axis in a figure embedded in Tkinter

I am writing a script with a matplotlib figure embedded in a Tkinter Frame :

fig=Figure()
ax=fig.add_subplot(111)
canvas = FigureCanvasTkAgg(fig, root)

and so on...

Everything goes well but when i try to clear the figure, the xaxis and yaxis
don't desappear, so that the next axis print over the previous ones.

ax.cla() clears the plot.
But ax.xaxis.cla() or ax.yaxis.cla() have no effect.

And fig.clr() seems to lock the process : nothing deleted, nothing new
ploted.

Can somebody help ? Thank you.

JD

···

--
View this message in context: http://old.nabble.com/Clearing-the-axis-in-a-figure-embedded-in-Tkinter-tp32054762p32054762.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

JD83, on 2011-07-13 08:59, wrote:

I am writing a script with a matplotlib figure embedded in a Tkinter Frame :

fig=Figure()
ax=fig.add_subplot(111)
canvas = FigureCanvasTkAgg(fig, root)

and so on...

Everything goes well but when i try to clear the figure, the xaxis and yaxis
don't desappear, so that the next axis print over the previous ones.

ax.cla() clears the plot.
But ax.xaxis.cla() or ax.yaxis.cla() have no effect.

as far as i can see, this is for resetting the formatting and
clearing labels - it does have an effect here:
In [16]: ax.set_ylabel("foo")
Out[16]: <matplotlib.text.Text at 0xb25a44c>

In [17]: ax.yaxis.cla() #label is gone

And fig.clr() seems to lock the process : nothing deleted, nothing new
ploted.

Try this:
f.clf(keep_observers=False)

from the docstring: "Set *keep_observers* to True if, for example,
a gui widget is tracking the axes in the figure."

best,

···

--
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7

Sorry, it doesn't work.
ax.set_ylabel("foo")
doesn't change anything (before "ax.yaxis.cla()").

And f.clf(keep_observers=False) still locks the process.

But maybe I used wrong terms. Here is the displays ; left before the
clearing ; right, after the clearing ; the plot is correctly renewed, but
the ticks labels are printed over the previous ones.
http://old.nabble.com/file/p32060191/Capture-6.png Capture-6.png

Thank you.
JD

···

--
View this message in context: http://old.nabble.com/Clearing-the-axis-in-a-figure-embedded-in-Tkinter-tp32054762p32060191.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Sorry, it doesn't work.
ax.set_ylabel("foo")
doesn't change anything (before "ax.yaxis.cla()").

And f.clf(keep_observers=False) still locks the process.

But maybe I used wrong terms. Here is the displays ; left before the
clearing ; right, after the clearing ; the plot is correctly renewed, but
the ticks labels are printed over the previous ones.
http://old.nabble.com/file/p32060202/Capture-6.png

Thank you.
JD

···

--
View this message in context: http://old.nabble.com/Clearing-the-axis-in-a-figure-embedded-in-Tkinter-tp32054762p32060202.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Hi JD,

I'm having exactly the same problem. Did you find a solution?

The only thing that I have noted so far is that when I plot for the second
time (when the axes start overlapping) if I move the cursor inside the
canvas area, it flickers and then the plots are displayed correctly. But it
only happens the first time.

Now, if you put a toolbar
self.toolbar = NavigationToolbar2TkAgg( self.canvas, self.PlotsContainer )

and you use any of the functions, say the zoom, then the flickering occurs
every time you pass over the white plotting area. The axes are updated (old
ones are gone) but the flickering is annoying. Plus you have to pretend you
want to zoom or something.

Besides that, I have been unsuccessful trying to tackle the issue.

Best,
johnmcpot

···

--
View this message in context: http://old.nabble.com/Clearing-the-axis-in-a-figure-embedded-in-Tkinter-tp32054762p32847767.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

johnmcpot wrote:

Hi JD,

I'm having exactly the same problem. Did you find a solution?

Hello

I have exactly the same problem while embedding matplotlib in PyQT4 on OS X
with backend_qt4agg.
I think I have found a solution : do you use frameon=False in this line :
fig = Figure(figsize=(width, height), dpi=dpi, frameon=False)

I did, and went back to True ... and no more axes update problems !!!

You can check this behavior in this tutorial : add the frameon=False, and
the axes are no more updating correctly (on OS X, didn't test it on Linux).
http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_qt4.html

Perhaps this is normal. If not I think I'll submit a bug report in
matplotlib's bugtracker.

Michka

···

--
View this message in context: http://old.nabble.com/Clearing-the-axis-in-a-figure-embedded-in-Tkinter-tp32054762p32875027.html
Sent from the matplotlib - users mailing list archive at Nabble.com.