Hi, I am wondering if there is a way to delete a Matplotlib graph embedded into a Tkinter canvas. This is because I want to be able to shift the position of the graph when a button is clicked.
This is the code I use to create the graph and embed it onto the canvas:
def click_for_plot(self):
self.graph = True
if self.graph == True:
matplotlib.use(‘TkAgg’)
self.second_frame.fig,self.second_frame.ax = plt.subplots()
self.second_frame.canvas = FigureCanvasTkAgg(self.second_frame.fig, self.second_frame)
self.second_frame.canvas.get_tk_widget().grid(row = self.row_count+1, column = 0)
axis_color = ‘lightgoldenrodyellow’
self.second_frame.fig2,self.second_frame.ax2 = plt.subplots()
self.second_frame.canvas2 = FigureCanvasTkAgg(self.second_frame.fig2,self.second_frame)
self.second_frame.canvas2.get_tk_widget().grid(row=self.row_count+2,column=0)
self.update_plot()
return
Thank you!