Concept Flow - Figure creation with plt.figure
Call plt.figure()
Create new Figure object
Figure ready for plotting
Add plots or axes
Show or save figure
This flow shows how calling plt.figure() creates a new empty figure ready for plotting.
import matplotlib.pyplot as plt fig = plt.figure() print(type(fig))
| Step | Action | Evaluation | Result |
|---|---|---|---|
| 1 | Import matplotlib.pyplot as plt | Module imported | plt module ready |
| 2 | Call plt.figure() | Create new figure object | <class 'matplotlib.figure.Figure'> |
| 3 | Print type(fig) | Evaluate type | <class 'matplotlib.figure.Figure'> |
| Variable | Start | After plt.figure() | Final |
|---|---|---|---|
| fig | undefined | Figure object | Figure object |
plt.figure() creates a new empty figure object. Assign it to a variable to modify or add plots. It does not display the figure automatically. Use plt.show() to display the figure. Useful for creating multiple figures in one script.