@@ -290,44 +290,60 @@ def my_plotter(ax, data1, data2, param_dict):
290
290
# "interactive backends") and hardcopy backends to make image files
291
291
# (PNG, SVG, PDF, PS; also referred to as "non-interactive backends").
292
292
#
293
- # There are three ways to configure your backend. If they conflict each other,
294
- # the method mentioned last in the following list will be used, e.g. calling
295
- # :func:`~matplotlib.use()` will override the setting in your ``matplotlibrc``.
293
+ # Selecting a backend
294
+ # -------------------
296
295
#
297
- # #. The :rc:`backend` parameter in your ``matplotlibrc`` file (see
298
- # :doc:`/tutorials/introductory/customizing`)::
296
+ # There are three ways to configure your backend:
297
+ #
298
+ # 1. The :rc:`backend` parameter in your ``matplotlibrc`` file
299
+ # 2. The :envvar:`MPLBACKEND` environment variable
300
+ # 3. The function :func:`matplotlib.use`
301
+ #
302
+ # A more detailed description is given below.
303
+ #
304
+ # If multiple of these are configurations are present, the last one from the
305
+ # list takes precedence; e.g. calling :func:`matplotlib.use()` will override
306
+ # the setting in your ``matplotlibrc``.
307
+ #
308
+ # If no backend is explicitly set, Matplotlib automatically detects a usable
309
+ # backend based on what is available on your system and on whether a GUI event
310
+ # loop is already running. On Linux, if the environment variable
311
+ # :envvar:`DISPLAY` is unset, the "event loop" is identified as "headless",
312
+ # which causes a fallback to a noninteractive backend (agg).
313
+ #
314
+ # Here is a detailed description of the configuration methods:
315
+ #
316
+ # #. Setting :rc:`backend` in your ``matplotlibrc`` file::
299
317
#
300
318
# backend : qt5agg # use pyqt5 with antigrain (agg) rendering
301
319
#
302
- # If no backend is explicitly set in the ``matplotlibrc`` file, Matplotlib
303
- # automatically detects a usable backend based on what is available on your
304
- # system and on whether a GUI event loop is already running.
320
+ # See also :doc:`/tutorials/introductory/customizing`.
305
321
#
306
- # On Linux, if the environment variable :envvar:`DISPLAY` is unset, the
307
- # "event loop" is identified as "headless", which causes a fallback to a
308
- # noninteractive backend (agg).
322
+ # #. Setting the :envvar:`MPLBACKEND` environment variable:
309
323
#
310
- # #. Setting the :envvar:`MPLBACKEND` environment variable, either for your
311
- # current shell or for a single script. On Unix::
324
+ # You can set the environment variable either for your current shell or for
325
+ # a single script.
312
326
#
313
- # > export MPLBACKEND=module://my_backend
327
+ # On Unix::
328
+ #
329
+ # > export MPLBACKEND=qt5agg
314
330
# > python simple_plot.py
315
331
#
316
- # > MPLBACKEND="module://my_backend " python simple_plot.py
332
+ # > MPLBACKEND="qt5agg " python simple_plot.py
317
333
#
318
334
# On Windows, only the former is possible::
319
335
#
320
- # > set MPLBACKEND=module://my_backend
336
+ # > set MPLBACKEND=qt5agg
321
337
# > python simple_plot.py
322
338
#
323
339
# Setting this environment variable will override the ``backend`` parameter
324
340
# in *any* ``matplotlibrc``, even if there is a ``matplotlibrc`` in your
325
- # current working directory. Therefore setting :envvar:`MPLBACKEND`
341
+ # current working directory. Therefore, setting :envvar:`MPLBACKEND`
326
342
# globally, e.g. in your ``.bashrc`` or ``.profile``, is discouraged as it
327
343
# might lead to counter-intuitive behavior.
328
344
#
329
- # #. If your script depends on a specific backend you can use the
330
- # :func:`~ matplotlib.use` function ::
345
+ # #. If your script depends on a specific backend you can use the function
346
+ # :func:`matplotlib.use`::
331
347
#
332
348
# import matplotlib
333
349
# matplotlib.use('PS') # generate postscript output by default
@@ -340,9 +356,9 @@ def my_plotter(ax, data1, data2, param_dict):
340
356
# use a different backend. Therefore, you should avoid explicitly calling
341
357
# `~matplotlib.use` unless absolutely necessary.
342
358
#
343
- # .. note::
344
- # Backend name specifications are not case-sensitive; e.g., 'GTK3Agg'
345
- # and 'gtk3agg' are equivalent.
359
+ #
360
+ # The builtlin backends
361
+ # ---------------------
346
362
#
347
363
# With a typical installation of matplotlib, such as from a
348
364
# binary installer or a linux distribution package, a good default
@@ -424,6 +440,10 @@ def my_plotter(ax, data1, data2, param_dict):
424
440
# This backend can be activated in IPython with ``%matplotlib wx``.
425
441
# ========= ================================================================
426
442
#
443
+ # .. note::
444
+ # Backend name specifications are case-insensitive; e.g., 'Qt5Agg'
445
+ # and 'qt5agg' are equivalent.
446
+ #
427
447
# .. _`Anti-Grain Geometry`: http://antigrain.com/
428
448
# .. _Postscript: https://en.wikipedia.org/wiki/PostScript
429
449
# .. _`Portable Document Format`: https://en.wikipedia.org/wiki/Portable_Document_Format
@@ -438,7 +458,7 @@ def my_plotter(ax, data1, data2, param_dict):
438
458
# .. _PyQt5: https://riverbankcomputing.com/software/pyqt/intro
439
459
#
440
460
# ipympl
441
- # ------
461
+ # ^^^^^^
442
462
#
443
463
# The Jupyter widget ecosystem is moving too fast to support directly in
444
464
# Matplotlib. To install ipympl
@@ -458,13 +478,13 @@ def my_plotter(ax, data1, data2, param_dict):
458
478
# for more details.
459
479
#
460
480
# GTK and Cairo
461
- # -------------
481
+ # ^^^^^^^^^^^^^
462
482
#
463
483
# `GTK3` backends (*both* `GTK3Agg` and `GTK3Cairo`) depend on Cairo
464
484
# (pycairo>=1.11.0 or cairocffi).
465
485
#
466
486
# How do I select PyQt4 or PySide?
467
- # --------------------------------
487
+ # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
468
488
#
469
489
# The `QT_API` environment variable can be set to either `pyqt` or `pyside`
470
490
# to use `PyQt4` or `PySide`, respectively.
@@ -473,10 +493,25 @@ def my_plotter(ax, data1, data2, param_dict):
473
493
# :mod:`matplotlib` first tries to import it, if the import fails, it tries to
474
494
# import `PySide`.
475
495
#
496
+ # Using non-builtin backends
497
+# --------------------------
498
+ # 3rd parties can provide additional backends. Some of them (e.g. jupyter and
499
+ # pycharm have their own way of activation). However, there is also a generic
500
+ # way to activate non-builtin backends. If you have a module ``my_backend``
501
+ # that implements a backend:
502
+ #
503
+ # a) Make sure, it can be imported (e.g. by regular installation or by putting
504
+ # it on the PYTHONPATH).
505
+ # b) Select the backend via one of the methods above by using
506
+ # ``module://my_backend`` as the backend name, e.g. ::
507
+ #
508
+ # matplotlib.use('module://my_backend')
509
+ #
510
+ #
476
511
# .. _interactive-mode:
477
512
#
478
513
# What is interactive mode?
479
- # ===================================
514
+ # =========================
480
515
#
481
516
# Use of an interactive backend (see :ref:`what-is-a-backend`)
482
517
# permits--but does not by itself require or ensure--plotting
0 commit comments