@@ -34,23 +34,57 @@ using Matplotlib, and what :ref:`Backend <what-is-a-backend>` you are using.
34
34
Notebooks and IDEs
35
35
------------------
36
36
37
+ .. figure :: /_static/FigureInline.png
38
+ :alt: Image of figure generated in Jupyter Notebook with inline backend.
39
+ :width: 400
40
+
41
+ Screenshot of a `Jupyter Notebook <https://jupyter.org >`_, with a figure
42
+ generated via the default `inline
43
+ <https://github.com/ipython/matplotlib-inline> `_ backend.
44
+
45
+
37
46
If you are using a Notebook (e.g. `Jupyter <https://jupyter.org >`_) or an IDE
38
47
that renders Notebooks (PyCharm, VSCode, etc), then they have a backend that
39
48
will render the Matplotlib Figure when a code cell is executed. One thing to
40
49
be aware of is that the default Jupyter backend (``%matplotlib inline ``) will
41
50
by default trim or expand the figure size to have a tight box around Artists
42
- added to the Figure (see :ref: `saving_figures `, below).
51
+ added to the Figure (see :ref: `saving_figures `, below). If you use a backend
52
+ other than the default "inline" backend, you will likely need to use an ipython
53
+ "magic" like ``%matplotlib notebook `` for the Matplotlib :ref: `notebook
54
+ <jupyter_notebooks_jupyterlab>` or ``%matplotlib widget `` for the `ipympl
55
+ <https://matplotlib.org/ipympl/> `_ backend.
56
+
57
+ .. figure :: /_static/FigureNotebook.png
58
+ :alt: Image of figure generated in Jupyter Notebook with notebook
59
+ backend, including a toolbar.
60
+ :width: 400
61
+
62
+ Screenshot of a Jupyter Notebook with an interactive figure generated via
63
+ the ``%matplotlib notebook `` magic. Users should also try the similar
64
+ `widget <https://matplotlib.org/ipympl/ >`_ backend if using `JupyterLab
65
+ <https://jupyterlab.readthedocs.io/en/stable/> `_.
66
+
67
+
68
+ .. seealso ::
69
+ :ref: `interactive_figures `.
43
70
44
71
Standalone scripts and interactive use
45
72
--------------------------------------
46
73
47
74
If the user is on a client with a windowing system, there are a number of
48
75
:ref: `Backends <what-is-a-backend >` that can be used to render the Figure to
49
- the screen, usually using a Python Qt, Tk, or Wx toolkit, though there is a native
50
- MacOS backend as well . These are typically chosen either in the user's
51
- :ref: ` matplotlibrc <customizing-with-matplotlibrc-files >`, or by calling
76
+ the screen, usually using a Python Qt, Tk, or Wx toolkit, or the native MacOS
77
+ backend. These are typically chosen either in the user's :ref: ` matplotlibrc
78
+ <customizing-with-matplotlibrc-files>`, or by calling, for example,
52
79
``matplotlib.use('QtAgg') `` at the beginning of a session or script.
53
80
81
+ .. figure :: /_static/FigureQtAgg.png
82
+ :alt: Image of figure generated from a script via the QtAgg backend.
83
+ :width: 370
84
+
85
+ Screenshot of a Figure generated via a python script and shown using the
86
+ QtAgg backend.
87
+
54
88
When run from a script, or interactively (e.g. from an
55
89
`iPython shell <https://https://ipython.readthedocs.io/en/stable/ >`_) the Figure
56
90
will not be shown until we call ``plt.show() ``. The Figure will appear in
@@ -64,6 +98,9 @@ Note that if you are on a client that does not have access to a windowing
64
98
system, the Figure will fallback to being drawn using the "Agg" backend, and
65
99
cannot be viewed, though it can be :ref: `saved <saving_figures >`.
66
100
101
+ .. seealso ::
102
+ :ref: `interactive_figures `.
103
+
67
104
.. _creating_figures :
68
105
69
106
Creating Figures
0 commit comments