matplotlib - Overwriting Existing Python Plots with New Function Call -
i overwrite existing plot made in python new function call. produce plot, @ it, call same function again different arguments produce plot. second plot replace first plot. is, don't want 2 figure windows open; original window overwritten. i have tried using interactive mode when plotting (ion()), placing plot() , show() calls in different places, , clearing figures. problems have that: 1. can never overwrite , existing window, open more 2. show() blocks code continuing , unable perform 2nd function call 3. use interactive mode , window appears second before going away what i'm trying seems simple enough, i'm having great difficulty. appreciated. write plotting function like def my_plotter(ax, data, style): ax.cla() # ax.whatever rest of plotting return artists_added and call like data = some_function() arts = my_plotter(plt.gca(), data, ...) or do fig, ax = plt.subplots() and call plotting function like arts = my_plotter(ax, data, ....