8000 Further improve backend tutorial. · matplotlib/matplotlib@2272a3e · GitHub
[go: up one dir, main page]

Skip to content

Commit 2272a3e

Browse files
committed
Further improve backend tutorial.
1) Don't do `use("ps")` (in practice one never needs to set that backend manually as we autoswitch to "ps" when saving a postscript); instead have `use("qt5agg")` as example. 2) The requirement to call `use()` before importing pyplot is obsolete. Actually even "use() needs to be called before creating any figure" is a bit too restrictive because switching to noninteractive backends is always possible... but no need to go into this in the intro tutorial. 3) Reword description of "default" backend selection.
1 parent 0f54425 commit 2272a3e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tutorials/introductory/usage.py

Lines changed: 10 additions & 10 deletions
7AAC
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,10 @@ def my_plotter(ax, data1, data2, param_dict):
345345
# :func:`matplotlib.use`::
346346
#
347347
# import matplotlib
348-
# matplotlib.use('PS') # generate postscript output by default
348+
# matplotlib.use('qt5agg')
349349
#
350-
# If you use the `~matplotlib.use` function, this should be done before
351-
# importing :mod:`matplotlib.pyplot`. Calling `~matplotlib.use` after pyplot
352-
# has been imported may fail to switch the backend and raise an ImportError.
350+
# This should be done before any figure is created; otherwise Matplotlib may
351+
# fail to switch the backend and raise an ImportError.
353352
#
354353
# Using `~matplotlib.use` will require changes in your code if users want to
355354
# use a different backend. Therefore, you should avoid explicitly calling
@@ -359,12 +358,13 @@ def my_plotter(ax, data1, data2, param_dict):
359358
# The builtin backends
360359
# --------------------
361360
#
362-
# With a typical installation of matplotlib, such as from a
363-
# binary installer or a linux distribution package, a good default
364-
# backend will already be set, allowing both interactive work and
365-
# plotting from scripts, with output to the screen and/or to
366-
# a file, so at least initially you will not need to use any of the
367-
# methods given above.
361+
# By default, Matplotlib should automatically select a default backend which
362+
# allows both interactive work and plotting from scripts, with output to the
363+
# screen and/or to a file, so at least initially you will not need to worry
364+
# about the backend. The most common exception is if your Python distribution
365+
# comes without :mod:`tkinter` and you have no other GUI toolkit installed;
366+
# this happens on certain Linux distributions, where you need to install a
367+
# Linux package named ``python-tk`` (or similar).
368368
#
369369
# If, however, you want to write graphical user interfaces, or a web
370370
# application server (:ref:`howto-webapp`), or need a better

0 commit comments

Comments
 (0)
0