How to clear a plot with MatplotlibOct 24th 2021 • 0 minSometimes, it might end up needing to clear a plot with Matplotlib.With the axes.clear() you clear the axis of a figure.Here is an exampleimport matplotlib.pyplot as plt import pandas as pd # We set up the example dataframe df = pd.DataFrame({"col1": range(10)}) # We set up our canvas fig, axes = plt.subplots(1,1, figsize=(10,10)) # We plot the col1 axes.plot(df["col1"]) # How to clear a plot with Matplotlib axes.clear() # We plot once again axes.plot(df["col1"]) plt.show()How to clear a plot with the .clear() methodHere you are! You know now how to clear a plot with the axes.clear() method.