@@ -11,17 +11,18 @@ Backends
11
11
What is a backend?
12
12
------------------
13
13
14
- A lot of documentation on the website and in the mailing lists refers
15
- to the "backend" and many new users are confused by this term.
16
- Matplotlib targets many different use cases and output formats. Some
17
- people use Matplotlib interactively from the Python shell and have
18
- plotting windows pop up when they type commands. Some people run
19
- `Jupyter <https://jupyter.org >`_ notebooks and draw inline plots for
20
- quick data analysis. Others embed Matplotlib into graphical user
21
- interfaces like PyQt or PyGObject to build rich applications. Some
22
- people use Matplotlib in batch scripts to generate postscript images
23
- from numerical simulations, and still others run web application
24
- servers to dynamically serve up graphs.
14
+ Backends are used for out-putting Matplotlib figures (see :ref: `figure-intro `),
15
+ to the screen or for writing to files. A lot of
16
+ documentation on the website and in the mailing lists refers to the "backend"
17
+ and many new users are confused by this term. Matplotlib targets many different
18
+ use cases and output formats. Some people use Matplotlib interactively from
19
+ the Python shell and have plotting windows pop up when they type commands.
20
+ Some people run `Jupyter <https://jupyter.org >`_ notebooks and draw inline
21
+ plots for quick data analysis. Others embed Matplotlib into graphical user
22
+ interfaces like PyQt or PyGObject to build rich applications. Some people use
23
+ Matplotlib in batch scripts to generate postscript images from numerical
24
+ simulations, and still others run web application servers to dynamically serve
25
+ up graphs.
25
26
26
27
To support all of these use cases, Matplotlib can target different
27
28
outputs, and each of these capabilities is called a backend; the
@@ -256,21 +257,23 @@ Debugging the figure windows not showing
256
257
257
258
Sometimes things do not work as expected, usually during an install.
258
259
259
- If you are using a Notebook or integrated development environment (PyCharm ),
260
+ If you are using a Notebook or integrated development environment (see :ref: ` notebooks-and-ides ` ),
260
261
please consult their documentation for debugging figures not working in their
261
262
environments.
262
263
263
- If you are using one of Matplotlib's graphics backends, make sure you know which
264
+ If you are using one of Matplotlib's graphics backends (see :ref: ` standalone-scripts-and-interactive-use `) , make sure you know which
264
265
one is being used:
265
266
266
267
.. code-block :: python3
268
+
267
269
import matplotlib
268
270
269
271
print(matplotlib.get_backend())
270
272
271
273
Try a simple plot, as see if the GUI opens:
272
274
273
275
.. code-block :: python3
276
+
274
277
import matplotlib
275
278
import matplotlib.pyplot as plt
276
279
287
290
^^^^
288
291
289
292
.. code-block :: bash
293
+
290
294
python -c " from PyQt5.QtWidgets import *; app = QApplication([]); win = QMainWindow(); win.show(); app.exec()"
291
295
292
296
If you have ``PySide `` or ``PyQT6 `` installed instead, just change the import
@@ -296,12 +300,14 @@ GTK
296
300
^^^
297
301
298
302
.. code-block :: bash
303
+
299
304
python3 -c ' from gi.repository import Gtk; win = Gtk.Window(); win.connect("destroy", Gtk.main_quit); win.show(); Gtk.main()'
300
305
301
306
wxPython
302
307
^^^^^^^^
303
308
304
309
.. code-block :: python3
310
+
305
311
import wx
306
312
307
313
app = wx.App(False) # Create a new app, don't redirect stdout/stderr to a window.
0 commit comments