Skip to content

Commit 93f5de4

Browse files
authored
Merge pull request matplotlib#27165 from mattymo30/main
Fixing Matplotlib Notebook Text
2 parents 5452efc + 97213e5 commit 93f5de4

File tree

2 files changed

+43
-33
lines changed

2 files changed

+43
-33
lines changed

galleries/users_explain/figure/figure_intro.rst

+9
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ other than the default "inline" backend, you will likely need to use an ipython
7373
.. seealso::
7474
:ref:`interactive_figures`.
7575

76+
.. note::
77+
78+
If you only need to use the classic notebook (i.e. ``notebook<7``),
79+
you can use:
80+
81+
.. sourcecode:: ipython
82+
83+
%matplotlib notebook
84+
7685
Standalone scripts and interactive use
7786
--------------------------------------
7887

galleries/users_explain/figure/interactive.rst

+34-33
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,16 @@ that include interactive tools, a toolbar, a tool-tip, and
3636
`.pyplot.subplots`
3737
Creates a new `.Figure` and fills it with a grid of `~.axes.Axes`
3838

39-
`.pyplot` has a notion of "The Current Figure" which can be accessed
40-
through `.pyplot.gcf` and a notion of "The Current Axes" accessed
41-
through `.pyplot.gca`. Almost all of the functions in `.pyplot` pass
42-
through the current `.Figure` / `~.axes.Axes` (or create one) as
43-
appropriate.
39+
`.pyplot.gcf`
40+
Get the current `.Figure`. If there is current no figure on the pyplot figure
41+
stack, a new figure is created
42+
43+
`.pyplot.gca`
44+
Get the current `~.axes.Axes`. If there is current no Axes on the Figure,
45+
a new one is created
46+
47+
Almost all of the functions in `.pyplot` pass through the current `.Figure` / `~.axes.Axes`
48+
(or create one) as appropriate.
4449

4550
Matplotlib keeps a reference to all of the open figures
4651
created via `pyplot.figure` or `pyplot.subplots` so that the figures will not be garbage
@@ -51,7 +56,6 @@ collected. `.Figure`\s can be closed and deregistered from `.pyplot` individuall
5156
.. seealso::
5257

5358
For more discussion of Matplotlib's event system and integrated event loops:
54-
5559
- :ref:`interactive_figures_and_eventloops`
5660
- :ref:`event-handling`
5761

@@ -189,7 +193,7 @@ the GUI main loop in some other way.
189193

190194
.. warning::
191195

192-
Using `.Figure.show` it is possible to display a figure on
196+
Using `.Figure.show`, it is possible to display a figure on
193197
the screen without starting the event loop and without being in
194198
interactive mode. This may work (depending on the GUI toolkit) but
195199
will likely result in a non-responsive figure.
@@ -211,8 +215,7 @@ Interactive navigation
211215
.. image:: ../../../_static/toolbar.png
212216

213217
All figure windows come with a navigation toolbar, which can be used
214-
to navigate through the data set. Here is a description of each of
215-
the buttons at the bottom of the toolbar
218+
to navigate through the data set.
216219

217220
.. image:: ../../../../lib/matplotlib/mpl-data/images/home_large.png
218221

@@ -221,20 +224,19 @@ the buttons at the bottom of the toolbar
221224
.. image:: ../../../../lib/matplotlib/mpl-data/images/forward_large.png
222225

223226
The ``Home``, ``Forward`` and ``Back`` buttons
224-
These are akin to a web browser's home, forward and back controls.
227+
These are similar to a web browser's home, forward and back controls.
225228
``Forward`` and ``Back`` are used to navigate back and forth between
226229
previously defined views. They have no meaning unless you have already
227230
navigated somewhere else using the pan and zoom buttons. This is analogous
228231
to trying to click ``Back`` on your web browser before visiting a
229232
new page or ``Forward`` before you have gone back to a page --
230-
nothing happens. ``Home`` always takes you to the
231-
first, default view of your data. Again, all of these buttons should
232-
feel very familiar to any user of a web browser.
233+
nothing happens. ``Home`` takes you to the
234+
first, default view of your data.
233235

234236
.. image:: ../../../../lib/matplotlib/mpl-data/images/move_large.png
235237

236238
The ``Pan/Zoom`` button
237-
This button has two modes: pan and zoom. Click the toolbar button
239+
This button has two modes: pan and zoom. Click the ``Pan/Zoom`` button
238240
to activate panning and zooming, then put your mouse somewhere
239241
over an axes. Press the left mouse button and hold it to pan the
240242
figure, dragging it to a new position. When you release it, the
@@ -244,8 +246,8 @@ The ``Pan/Zoom`` button
244246
the right mouse button to zoom, dragging it to a new position.
245247
The x axis will be zoomed in proportionately to the rightward
246248
movement and zoomed out proportionately to the leftward movement.
247-
The same is true for the y axis and up/down motions. The point under your
248-
mouse when you begin the zoom remains stationary, allowing you to
249+
The same is true for the y axis and up/down motions (up zooms in, down zooms out).
250+
The point under your mouse when you begin the zoom remains stationary, allowing you to
249251
zoom in or out around that point as much as you wish. You can use the
250252
modifier keys 'x', 'y' or 'CONTROL' to constrain the zoom to the x
251253
axis, the y axis, or aspect ratio preserve, respectively.
@@ -257,9 +259,8 @@ The ``Pan/Zoom`` button
257259

258260
.. image:: ../../../../lib/matplotlib/mpl-data/images/zoom_to_rect_large.png
259261

260-
The ``Zoom-to-rectangle`` button
261-
Click this toolbar button to activate this mode. Put your mouse somewhere
262-
over an axes and press a mouse button. Define a rectangular region by
262+
The ``Zoom-to-Rectangle`` button
263+
Put your mouse somewhere over an axes and press a mouse button. Define a rectangular region by
263264
dragging the mouse while holding the button to a new location. When using
264265
the left mouse button, the axes view limits will be zoomed to the defined
265266
region. When using the right mouse button, the axes view limits will be
@@ -268,8 +269,8 @@ The ``Zoom-to-rectangle`` button
268269
.. image:: ../../../../lib/matplotlib/mpl-data/images/subplots_large.png
269270

270271
The ``Subplot-configuration`` button
271-
Use this tool to configure the appearance of the subplot:
272-
you can stretch or compress the left, right, top, or bottom
272+
Use this button to configure the appearance of the subplot.
273+
You can stretch or compress the left, right, top, or bottom
273274
side of the subplot, or the space between the rows or
274275
space between the columns.
275276

@@ -325,7 +326,7 @@ Interactive mode works in the default Python prompt:
325326
>>> plt.ion()
326327
>>>
327328

328-
however this does not ensure that the event hook is properly installed
329+
However, this does not ensure that the event hook is properly installed
329330
and your figures may not be responsive. Please consult the
330331
documentation of your GUI toolkit for details.
331332

@@ -335,16 +336,6 @@ documentation of your GUI toolkit for details.
335336
Jupyter Notebooks / JupyterLab
336337
------------------------------
337338

338-
.. note::
339-
340-
To get the interactive functionality described here, you must be
341-
using an interactive backend. The default backend in notebooks,
342-
the inline backend, is not. `~ipykernel.pylab.backend_inline`
343-
renders the figure once and inserts a static image into the
344-
notebook when the cell is executed. Because the images are static, they
345-
cannot be panned / zoomed, take user input, or be updated from other
346-
cells.
347-
348339
To get interactive figures in the 'classic' notebook or Jupyter lab,
349340
use the `ipympl <https://matplotlib.org/ipympl>`__ backend
350341
(must be installed separately) which uses the **ipywidget** framework.
@@ -356,7 +347,7 @@ If ``ipympl`` is installed use the magic:
356347

357348
to select and enable it.
358349

359-
If you only need to use the classic notebook, you can use
350+
If you only need to use the classic notebook (i.e. ``notebook<7``), you can use
360351

361352
.. sourcecode:: ipython
362353

@@ -365,6 +356,16 @@ If you only need to use the classic notebook, you can use
365356
which uses the `.backend_nbagg` backend provided by Matplotlib;
366357
however, nbagg does not work in Jupyter Lab.
367358

359+
.. note::
360+
361+
To get the interactive functionality described here, you must be
362+
using an interactive backend. The default backend in notebooks,
363+
the inline backend, is not. `~ipykernel.pylab.backend_inline`
364+
renders the figure once and inserts a static image into the
365+
notebook when the cell is executed. Because the images are static, they
366+
cannot be panned / zoomed, take user input, or be updated from other
367+
cells.
368+
368369
GUIs + Jupyter
369370
^^^^^^^^^^^^^^
370371

0 commit comments

Comments
 (0)