Does mixing pyplot state-machine and Object-Oriented API cause figure reference conflicts?
0 reputation · 03 Sept 2021, 08:05 UTC
Matplotlib provides two primary interfaces for creating visualizations: the pyplot state-machine and the Object-Oriented (OO) API. While the OO API allows for explicit management of Figure and Axes objects, pyplot maintains a global state to track the active figure and current axes.
In complex applications where both interfaces are used simultaneously, there is uncertainty regarding how the global state is updated when an Axes object is manipulated via an explicit reference rather than through plt.gca(). This is particularly relevant when managing multiple figures in a non-interactive environment.
- Does modifying an
Axesobject created viaplt.subplots()automatically update the current axes tracked by thepyplotstate? - What is the deterministic behavior when
plt.plot()is called immediately after an explicit OO method call on a different figure?