0

How to integrate a matplotlib subplot inside a Tkinter frame, so that I can update it on each iteration? Currently, I have defined four quadrants as four frames inside a Tkinter master, and there is a button which will call a function, which will perform some calculation and plot the result in the subplot (to be integrated into one of the frames). I am having issues in plotting new data on the same plot. A new plot is always getting created on each call. (see ss, yellow region is a different frame)enter image description here Here is my code snippet(written inside the function being called through button widget):

'''figure = plt.Figure(figsize=(3.5,3.5), dpi=100)
    ax = figure.add_subplot(111)
    ax.plot(t,Ps)
    chart_type = FigureCanvasTkAgg(figure, master=f2)
    chart_type.draw()
    chart_type.get_tk_widget().grid()'''
Heisenberg
  • 27
  • 6
  • Will the new plot replace the previous plot in the `frame` or will the `frame` hold both the former plot and the new one from your recent calculations? – Samuel Kazeem Aug 16 '20 at 13:22
  • Currently with each call a new plot is getting created in the frame, but I just want to update the plot with new data and clear out old data, instead of generating separate plot for the new – Heisenberg Aug 16 '20 at 13:41
  • See [how-to-update-a-plot-in-matplotlib](https://stackoverflow.com/questions/4098131/how-to-update-a-plot-in-matplotlib/4098938). – acw1668 Aug 16 '20 at 14:04

0 Answers0