Skip to content

Commit 44f2e00

Browse files
authored
Merge pull request #32414 from QianyeSu/docs/fix-gui-gallery-header
DOC: clarify figure creation in GUI embedding overview
2 parents 266c9a3 + 94ccc1d commit 44f2e00

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎galleries/examples/user_interfaces/GALLERY_HEADER.rst‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ You can embed Matplotlib directly into a user interface application by
77
following the embedding_in_SOMEGUI.py examples here. Currently
88
Matplotlib supports PyQt/PySide, PyGObject, Tkinter, and wxPython.
99

10-
When embedding Matplotlib in a GUI, you must use the Matplotlib API
11-
directly rather than the pylab/pyplot procedural interface, so take a
12-
look at the examples/api directory for some example code working with
13-
the API.
10+
When embedding Matplotlib in a GUI, use standalone `.Figure` objects only.
11+
Do not use pyplot, because you do not want to depend on its globally managed
12+
state and its event loop control. In particular, use ``fig = Figure()`` rather
13+
than ``plt.figure()``, and ``fig = Figure(); axs = fig.subplots()`` rather than
14+
``fig, axs = plt.subplots()``. The examples below show how to connect these
15+
figures to the supported GUI toolkits.

0 commit comments

Comments
 (0)