Deleting a FigureCanvasTkAgg object

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:
self.second_frame.fig, = 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)

Thank you!

If you want to embed directly into a Tk window, you should not use plt.subplots, as that creates a Tk window for you. See Embedding in Tk — Matplotlib 3.7.0 documentation for an example of embedding in Tk.