import matplotlib.pyplot as plt fig = plt.figure(figsize=(5, 5)) plt.plot([1, 2, 3], [4, 5, 6]) fig.clf()
import numpy as np import matplotlib.pyplot as plt x = np.linspace(1, 10, 100) y = np.sin(x) fig = plt.figure(figsize=(5, 5)) plt.plot(x, y) fig.clf()This example generates a sine wave on the figure and then clears the figure using clf(). The package used for the code examples is the matplotlib.figure library in Python.