I wanna control my plot embedded in a tkinter gui with a navigationtoolbar
here my code:
import matplotlib
matplotlib.use("tkagg")
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import figureCanvasTkAgg, NavigationToolbar2TkAgg
class Application(tk.Frame):
def __init__(self, master=None):
fig=plt.figure()
ax=fig.add_axes([0.1,0.1,0.8,0.8],polar=True)
tk.Frame.__init__(self,master)
toolbar_frame=tk.Frame(root)
toolbar_frame.grid(row=50, column=1)
canvas=FigureCanvasTkAgg(fig,master=root)
canvas.get_tk_widget().grid(row=0, column=1)
canvas.show()
toolbar=NavigationToolbar2TkAgg(canvas,toolbar_frame)
toolbar.update()
def plot(self):
ax.plot(some data)
canvas.show()
ax.clear()
#set axes
root.after(10,self.plot)
A button calls the plot function for the first time, but i guess this is not important at this place. The data is plotted every 10ms in the polar plot in the GUI. This works fine. When I stop the loop, I wanna work with the current data in the polar plot. I see the navigationbar and can click on the buttons. But if I select for example the zoom rectangle item nothing happens. If I click the home button or the next or previous button all my data points get wiped out.
So someone an idea how to handle it?
Thanks!