0

I'm using matplotlib inside a tkinter window so I can only use .figure() as this is what the FigureCanvas accepts. When i display another plot it adds another plot to my window next to the previous one. Is there a way to swap the plot so to only show one plot at a time and somehow delete the previous one? I have tried using .clf() but have had trouble.

Here is part of the code:

    plt.title(title)
    plt.xlabel('Months')
    plt.ylabel('Sales Volume')
    plt.xticks(rotation=30)
    global f
    f = Figure()
    f.add_subplot(111).plot(valueArray2, valueArray)
    canvas = FigureCanvasTkAgg(f, master=root)  # A tk.DrawingArea.
    canvas.draw()
    canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=1)

Graph1

Graph2

I only want one subplot at all times

0 Answers0