Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cc3ac5b

Browse files
committed
DOC: address review comments
1 parent b0690ff commit cc3ac5b

3 files changed

Lines changed: 44 additions & 40 deletions

File tree

doc/users/interactive.rst

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,27 @@ packages provide bindings to `kivy
2222
"live" the GUI event loop will need to be integrated with your prompt. The
2323
simplest way is to use IPython (see :ref:`below <ipython-pylab>`).
2424

25-
The `.pyplot` module provides two functions for creating Figures that,
26-
when an interactive backend is used, that are managed by Matplotlib,
27-
embedded in GUI windows, and ready for interactive use out of the box
25+
The `.pyplot` module provides functions for explicitly creating
26+
Figures that include a interactive tools, a toolbar, a tool-tip, and
27+
:ref:`key bindings <key-event-handling>` ready to go:
2828

2929
`.pyplot.figure`
3030
Creates a new empty `.figure.Figure` or selects an existing figure
3131

3232
`.pyplot.subplots`
3333
Creates a new `.figure.Figure` and fills it with a grid of `.axes.Axes`
3434

35-
Matplotlib keeps a reference to all of the open figures created this
36-
way so they will not be garbage collected. You can close all of your
37-
open figures via ``plt.close('all')``.
35+
`.pyplot` has a notion of "The Current Figure" which can be accessed
36+
through `.pyplot.gcf` and a notion of "The Current Axes" accessed
37+
through `.pyplot.gca`. Almost all of the function is `.pyplot` as pass
38+
through to the current `.Figure` / `.axes.Axes` (or create one) as
39+
appropriate. Matplotlib keeps a reference to all of the open figures
40+
created this way so they will not be garbage collected. You can close
41+
and deregister `.Figure`\s from from `.pyplot` individually via
42+
`.pyplot.close` or close all open figures via ``plt.close('all')``.
3843

39-
For discussion of how this works under the hood see:
44+
For discussion of how the integration of the event loops and Matplotlib's event
45+
system work under the hood see:
4046

4147
.. toctree::
4248
:maxdepth: 1
@@ -172,7 +178,7 @@ figures will only be "live" when the GUI event loop is running (via
172178
loop).
173179

174180

175-
.. warning
181+
.. warning::
176182

177183
Using `.figure.Figure.show` it is possible to display a figure on
178184
the screen without starting the event loop and without being in
@@ -196,28 +202,29 @@ Navigation Keyboard Shortcuts
196202
-----------------------------
197203

198204
The following table holds all the default keys, which can be
199-
overwritten by use of your matplotlibrc (#keymap.\*).
200-
201-
================================== =================================================
202-
Command Keyboard Shortcut(s)
203-
================================== =================================================
204-
Home/Reset **h** or **r** or **home**
205-
Back **c** or **left arrow** or **backspace**
206-
Forward **v** or **right arrow**
207-
Pan/Zoom **p**
208-
Zoom-to-rect **o**
209-
Save **ctrl** + **s**
210-
Toggle fullscreen **f** or **ctrl** + **f**
211-
Close plot **ctrl** + **w**
212-
Close all plots **shift** + **w**
205+
overwritten by use of your :ref:`matplotlibrc
206+
<sphx_glr_tutorials_introductory_customizing.py>`.
207+
208+
================================== ===============================
209+
Command Default key binding and rcParam
210+
================================== ===============================
211+
Home/Reset :rc:`keymap.home`
212+
Back :rc:`keymap.back`
213+
Forward :rc:`keymap.forward`
214+
Pan/Zoom :rc:`keymap.pan`
215+
Zoom-to-rect :rc:`keymap.zoom`
216+
Save :rc:`keymap.save`
217+
Toggle fullscreen :rc:`keymap.fullscreen`
218+
Toggle major grids :rc:`keymap.grid`
219+
Toggle minor grids :rc:`keymap.grid_minor`
220+
Toggle x axis scale (log/linear) :rc:`keymap.xscale`
221+
Toggle y axis scale (log/linear) :rc:`keymap.yscale`
222+
Toggle y axis scale (log/linear) :rc:`keymap.yscale`
223+
Close Figure :rc:`keymap.quit`
213224
Constrain pan/zoom to x axis hold **x** when panning/zooming with mouse
214225
Constrain pan/zoom to y axis hold **y** when panning/zooming with mouse
215226
Preserve aspect ratio hold **CONTROL** when panning/zooming with mouse
216-
Toggle major grids **g** when mouse is over an axes
217-
Toggle minor grids **G** when mouse is over an axes
218-
Toggle x axis scale (log/linear) **L** or **k** when mouse is over an axes
219-
Toggle y axis scale (log/linear) **l** when mouse is over an axes
220-
================================== =================================================
227+
================================== ===============================
221228

222229

223230
.. _other-shells:
@@ -278,17 +285,13 @@ end.
278285
GUIs + jupyter
279286
~~~~~~~~~~~~~~
280287

281-
If you are running your jupyter server locally you can use one of the
282-
GUI backends. However if you ever move that notebook to a remote
283-
server it will cease to work correctly because the GUI windows will be
284-
created on the server, not your machine. When you create a figure the
285-
process running your kernel creates and shows a GUI window. If that
286-
process is on the same computer as your client, then you will be able
287-
to see and interact with the window. However if it is running on a
288-
remote computer it will try to open the GUI window on _that_ computer.
289-
This will either fail by raising an exception (as many servers
290-
do not have an XServer running) or run, but leave you with no
291-
way to access your figure.
288+
If you are running your jupyter kernel locally you can use one of the
289+
GUI backends. Process running your kernel will and shows a GUI window
290+
on your desktop adjacent to your web browser. However if you move
291+
that notebook to a remote server the kernel will try to open the GUI
292+
window on _that_ computer. Unless you have arrange to forward the
293+
xserver back to your desktop, you not be able to see or interact with
294+
the figure (if it does not raise an exception outright).
292295

293296

294297

doc/users/interactive_guide.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ For example, if you want to poll for data you could use something like ::
230230
while True:
231231
x, y = get_new_data()
232232
ln.set_data(x, y)
233-
fig.canvas.draw_idle()
234233
plt.pause(1)
235234

236235
which would poll for new data and update the figure at 1Hz.

lib/matplotlib/pyplot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,14 +390,16 @@ def ion():
390390

391391
def pause(interval):
392392
"""
393-
Run the GUI event loop or sleep for *interval* seconds and .
393+
Run the GUI event loop for *interval* seconds.
394394
395395
If there is an active figure, it will be updated and displayed before the
396396
pause, and the GUI event loop (if any) will run during the pause.
397397
398398
This can be used for crude animation. For more complex animation use
399399
:mod:`matplotlib.animation`.
400400
401+
If there is no active figure, sleep for *interval* seconds instead.
402+
401403
See Also
402404
--------
403405
matplotlib.animation : Complex animation

0 commit comments

Comments
 (0)