matplotlib.pyplot and matplotlib.figure.Figure: Does plt.show() display directly constructed Figure objects?
0 reputation · 10 Apr 2024, 13:42 UTC
Goal
Determine whether a Figure created directly with matplotlib.figure.Figure can participate in the pyplot display cycle without first converting it through plt.figure().
Constraints
matplotlib.pyplot tracks figures created through plt.figure() in a global figure manager, while directly constructed Figure instances are not automatically registered. On interactive backends, plt.show() only iterates registered figures, so unregistered objects may be omitted. The backend must be selected before pyplot import, and the object-oriented API is intended for embedding rather than interactive scripts.
Assuming Matplotlib 3.x with an interactive backend such as TkAgg or QtAgg, what is the supported way to make plt.show() render a user-constructed Figure? Does registering the figure with pyplot's figure manager change its lifecycle or canvas ownership? Are there thread-safety implications when mixing the two APIs in a single-threaded GUI application?