3
3
You can adapt this file completely to your liking, but it should at least
4
4
contain the root `toctree` directive.
5
5
6
- mpl-gui Documentation
7
- =====================
6
+ =======================
7
+ mpl-gui Documentation
8
+ =======================
8
9
9
10
.. toctree ::
10
11
:maxdepth: 2
@@ -14,7 +15,7 @@ mpl-gui Documentation
14
15
15
16
16
17
Motivation
17
- ----------
18
+ ==========
18
19
19
20
This project is a prototype space for overhauling the GUI event loop management
20
21
tools that Matplotlib provides in pyplot.
@@ -35,7 +36,7 @@ Python.
35
36
36
37
37
38
Examples
38
- --------
39
+ ========
39
40
40
41
.. highlight :: python
41
42
@@ -49,8 +50,8 @@ If you want to be sure that this code does not secretly depend on pyplot run ::
49
50
which will prevent pyplot from being imported!
50
51
51
52
52
- show
53
- ++++
53
+ showing
54
+ -------
54
55
55
56
The core of the API is `~.show ` ::
56
57
@@ -65,31 +66,33 @@ The core of the API is `~.show` ::
65
66
66
67
67
68
which will show both figures and block until they are closed. As part of the
68
- "showing" process, the correct `
69
+ "showing" process, the correct GUI objects will be created, put on the
70
+ screen, and the event loop for the host GUI framework is run.
69
71
70
72
71
- blocking
72
- ++++++++
73
+ blocking (or not)
74
+ +++++++++++++++++
73
75
74
- Similar to ``plt.ion`` and ``plt.ioff ``, we provide ``mg.ion() `` and
75
- ``mg.ioff() `` which have identical semantics. Thus :::
76
+ Similar to `plt.ion<matplotlib.pyplot.ion> ` and
77
+ `plt.ioff<matplotlib.pyplot.ioff> `, we provide `mg.ion()<mpl_gui.ion> ` and
78
+ `mg.ioff()<mpl_gui.ioff> ` which have identical semantics. Thus ::
76
79
77
80
import mpl_gui as mg
78
81
from matplotlib.figure import Figure
79
82
80
83
mg.ion()
81
-
84
+ print(mg.is_interactive())
82
85
fig = Figure()
83
86
84
87
mg.show([fig]) # will not block
85
88
86
89
mg.ioff()
87
-
90
+ print(mg.is_interactive())
88
91
mg.show([fig]) # will block!
89
92
90
93
91
- As with `` plt.show `` , you can explicitly control the blocking behavior of
92
- `` mg.show ` ` via the *block * keyword argument ::
94
+ As with `plt.show<matplotlib.pyplot.show> ` , you can explicitly control the
95
+ blocking behavior of ` mg.show<.show> ` via the *block * keyword argument ::
93
96
94
97
import mpl_gui as mg
95
98
from matplotlib.figure import Figure
@@ -100,8 +103,12 @@ As with ``plt.show``, you can explicitly control the blocking behavior of
100
103
mg.show([fig], block=True) # will always block
101
104
102
105
106
+ The interactive state is shared Matplotlib and can also be controlled with
107
+ `matplotlib.interactive ` and queried via `matplotlib.is_interactive `.
108
+
109
+
103
110
Figure and Axes Creation
104
- ++++++++++++++++++++++++
111
+ ------------------------
105
112
106
113
In analogy with `matplotlib.pyplot ` we also provide `~mpl_gui.figure `,
107
114
`~mpl_gui.subplots ` and `~mpl_gui.subplot_mosaic ` ::
@@ -113,14 +120,14 @@ In analogy with `matplotlib.pyplot` we also provide `~mpl_gui.figure`,
113
120
114
121
mg.show([fig1, fig2, fig3])
115
122
116
- If `` mpl_gui `` is in "interactive mode",`~ mpl_gui.figure`,
117
- `mpl_gui.subplots ` and ` mpl_gui. subplot_mosaic ` will automatically put the new Figure in a window on the
118
- screen.
123
+ If `mpl_gui ` is in "interactive mode", ` mpl_gui.figure `, ` mpl_gui.subplots ` and
124
+ `mpl_gui.subplot_mosaic ` will automatically put the new Figure in a window on
125
+ the screen (but not run the event loop) .
119
126
120
127
121
128
122
129
FigureRegistry
123
- ++++++++++++++
130
+ --------------
124
131
125
132
In the above examples it is the responsibility of the user to keep track of the
126
133
`~matplotlib.figure.Figure ` instances that are created. If the user does not keep a hard
@@ -170,7 +177,7 @@ a dictionary mapping the Figures' labels to each Figure ::
170
177
fr.by_label['B'] is figB
171
178
172
179
FigureContext
173
- +++++++++++++
180
+ -------------
174
181
175
182
A very common use case is to make several figures and then show them all
176
183
together at the end. To facilitate this we provide a sub-class of
@@ -188,3 +195,17 @@ track of the created figures and shows them on exit ::
188
195
This will create 3 figures and block on ``__exit__ ``. The blocking
189
196
behavior depends on ``mg.is_interacitve() `` (and follow the behavior of
190
197
``mg.show `` or can explicitly controlled via the *block * keyword argument).
198
+
199
+
200
+ Selecting the GUI toolkit
201
+ -------------------------
202
+
203
+ `mpl_gui ` makes use of `Matplotlib backends
204
+ <https://matplotlib.org/stable/users/explain/backends.html> `_ for actually
205
+ providing the GUI bindings. Analagous to `matplotlib.use ` and
206
+ `matplotlib.pyplot.switch_backend ` `mpl_gui ` provides
207
+ `mpl_gui.select_gui_toolkit ` to select which GUI toolkit is used.
208
+ `~mpl_gui.select_gui_toolkit ` has the same fall-back behavior as
209
+ `~matplotlib.pyplot ` and stores its state in :rc: `backend `. `mpl_gui ` will
210
+ consistently co-exist with `matplotlib.pyplot ` managed Figures in the same
211
+ process.
0 commit comments