8000 DOC: Start to document interactive figures by tacaswell · Pull Request #4779 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

DOC: Start to document interactive figures #4779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
May 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
cfa717a
DOC: Start to document interactive figures
tacaswell Jul 24, 2015
206f99c
DOC: improve text
tacaswell Jul 31, 2015
fa36c95
DOC: address comments
tacaswell Jan 7, 2017
8b28c01
DOC/WIP: updates to docs on how event loops work
tacaswell Jul 28, 2017
7189eed
DOC: add blocking_input docs
tacaswell Dec 28, 2017
98ae26c
WIP: Lots of text changes to interactive guide
tacaswell Dec 28, 2017
6263284
MNT: add warnings to Figure.show
tacaswell Dec 29, 2017
09deda3
DOC: re-arrange shell.rst and interactive.rst
tacaswell Jan 3, 2018
ec4230a
DOC/WIP: more edits and content
tacaswell Jul 10, 2018
d1a7a3e
WIP: more notes
tacaswell Mar 2, 2019
b49973a
DOC: merge the blocking API docs together
tacaswell Apr 28, 2020
bb8058a
DOC: remove rst files that have been merged into interactive.rst
tacaswell Apr 28, 2020
bc4ecd5
DOC: fix and sort intersphinx
tacaswell Apr 28, 2020
49f49fa
DOC: re-write pyplot.show docstring
tacaswell Apr 29, 2020
295d71d
DOC: plt.pause is no longer experimental
tacaswell Apr 29, 2020
c3c5013
DOC: update pyplot documentation
tacaswell Apr 30, 2020
d9df057
DOC: Lots of editing to interactive figure documentation
tacaswell Apr 30, 2020
7b0b327
DOC: it's -> its
tacaswell Apr 30, 2020
5a426d6
DOC: spelling
tacaswell Apr 30, 2020
8ab0a65
DOC: edits from review
tacaswell May 1, 2020
d70d5ad
DOC: update skipped references
tacaswell May 1, 2020
757e040
DOC: correct many spelling / grammer / clarity issues
tacaswell May 3, 2020
b0690ff
DOC: remove badly named and superfluous heading
tacaswell May 7, 2020
cc3ac5b
DOC: address review comments
tacaswell May 7, 2020
afe9edd
DOC: edits from review
tacaswell May 7, 2020
e09cab9
DOC: more small edits
tacaswell May 7, 2020
04f2fc6
DOC: fix spyder spelling
tacaswell May 7, 2020
9d842bf
DOC: edits from review
tacaswell May 7, 2020
41e19a8
MNT: remove unused import
tacaswell May 7, 2020
eda2ed3
DOC: edits from review
tacaswell May 9, 2020
7cf68e8
DOC: remove non-existent function call
tacaswell May 9, 2020
bfa3589
DOC: edits and duplicate removal
tacaswell May 9, 2020
6edcb47
DOC: windows not widows
tacaswell May 9, 2020
9b492bd
DOC: Revert all changes to blocking_input_api.rst
tacaswell May 9, 2020
6d4747f
DOC: reduce jargon and correct grammar
tacaswell May 20, 2020
f05ea3d
DOC: grammar / wording corrections from review
tacaswell May 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
Prev Previous commit
Next Next commit
DOC: address review comments
  • Loading branch information
tacaswell committed May 7, 2020
commit cc3ac5ba55640c8d6ef40b23770336bd841e9c9c
79 changes: 41 additions & 38 deletions doc/users/interactive.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,27 @@ packages provide bindings to `kivy
"live" the GUI event loop will need to be integrated with your prompt. The
simplest way is to use IPython (see :ref:`below <ipython-pylab>`).

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

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

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

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

For discussion of how this works under the hood see:
For discussion of how the integration of the event loops and Matplotlib's event
system work under the hood see:

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


.. warning
.. warning::

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

The following table holds all the default keys, which can be
overwritten by use of your matplotlibrc (#keymap.\*).

================================== =================================================
Command Keyboard Shortcut(s)
================================== =================================================
Home/Reset **h** or **r** or **home**
Back **c** or **left arrow** or **backspace**
Forward **v** or **right arrow**
Pan/Zoom **p**
Zoom-to-rect **o**
Save **ctrl** + **s**
Toggle fullscreen **f** or **ctrl** + **f**
Close plot **ctrl** + **w**
Close all plots **shift** + **w**
overwritten by use of your :ref:`matplotlibrc
<sphx_glr_tutorials_introductory_customizing.py>`.

================================== ===============================
Command Default key binding and rcParam
================================== ===============================
Home/Reset :rc:`keymap.home`
Back :rc:`keymap.back`
Forward :rc:`keymap.forward`
Pan/Zoom :rc:`keymap.pan`
Zoom-to-rect :rc:`keymap.zoom`
Save :rc:`keymap.save`
Toggle fullscreen :rc:`keymap.fullscreen`
Toggle major grids :rc:`keymap.grid`
Toggle minor grids :rc:`keymap.grid_minor`
Toggle x axis scale (log/linear) :rc:`keymap.xscale`
Toggle y axis scale (log/linear) :rc:`keymap.yscale`
Toggle y axis scale (log/linear) :rc:`keymap.yscale`
Close Figure :rc:`keymap.quit`
Constrain pan/zoom to x axis hold **x** when panning/zooming with mouse
Constrain pan/zoom to y axis hold **y** when panning/zooming with mouse
Preserve aspect ratio hold **CONTROL** when panning/zooming with mouse
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed only for zooming, I think; panning never changes the aspect ratio.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right-click pan will change the view limits and respect this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never heard of right-click pan before, as far as I know. Maybe I've never stumbled over it because I use the Mac trackpad rather than a mouse.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right-click zoom zooms out (by putting the current view limits to be where the box you drew was)

Toggle major grids **g** when mouse is over an axes
Toggle minor grids **G** when mouse is over an axes
Toggle x axis scale (log/linear) **L** or **k** when mouse is over an axes
Toggle y axis scale (log/linear) **l** when mouse is over an axes
================================== =================================================
================================== ===============================


.. _other-shells:
Expand Down Expand Up @@ -278,17 +285,13 @@ end.
GUIs + jupyter
~~~~~~~~~~~~~~

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



Expand Down
1 change: 0 additions & 1 deletion doc/users/interactive_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ For example, if you want to poll for data you could use something like ::
while True:
x, y = get_new_data()
ln.set_data(x, y)
fig.canvas.draw_idle()
plt.pause(1)

which would poll for new data and update the figure at 1Hz.
Expand Down
4 changes: 3 additions & 1 deletion lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,14 +390,16 @@ def ion():

def pause(interval):
"""
Run the GUI event loop or sleep for *interval* seconds and .
Run the GUI event loop for *interval* seconds.

If there is an active figure, it will be updated and displayed before the
pause, and the GUI event loop (if any) will run during the pause.

This can be used for crude animation. For more complex animation use
:mod:`matplotlib.animation`.

If there is no active figure, sleep for *interval* seconds instead.

See Also
--------
matplotlib.animation : Complex animation
Expand Down
0