Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8971ab0

Browse files
authored
Merge pull request#16281 from anntzer/pgfd
Update/cleanup pgf tutorial.
2 parentscce331d +a8071f1 commit8971ab0

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

‎tutorials/text/pgf.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@
55
66
How to typeset text with the ``pgf`` backend in Matplotlib.
77
8-
Using the ``pgf`` backend,matplotlib can export figures as pgf drawing
8+
Using the ``pgf`` backend,Matplotlib can export figures as pgf drawing
99
commands that can be processed with pdflatex, xelatex or lualatex. XeLaTeX and
10-
LuaLaTeX have fullunicode support and can use any font that is installed in
10+
LuaLaTeX have fullUnicode support and can use any font that is installed in
1111
the operating system, making use of advanced typographic features of OpenType,
1212
AAT and Graphite. Pgf pictures created by ``plt.savefig('figure.pgf')``
1313
can be embedded as raw commands in LaTeX documents. Figures can also be
14-
directly compiled and saved to PDF with ``plt.savefig('figure.pdf')`` by either
15-
switching to the backend
16-
17-
.. code-block:: python
14+
directly compiled and saved to PDF with ``plt.savefig('figure.pdf')`` by
15+
switching the backend ::
1816
1917
matplotlib.use('pgf')
2018
21-
orregistering it for handling pdf output
19+
orby explicitly requesting the use of the ``pgf`` backend ::
2220
23-
.. code-block:: python
21+
plt.savefig('figure.pdf', backend='pgf')
22+
23+
or by registering it for handling pdf output ::
2424
2525
from matplotlib.backends.backend_pgf import FigureCanvasPgf
2626
matplotlib.backend_bases.register_backend('pdf', FigureCanvasPgf)
2727
28-
Thesecond method allows you to keep using regular interactive backends and to
28+
Thelast method allows you to keep using regular interactive backends and to
2929
save xelatex, lualatex or pdflatex compiled PDF files from the graphical user
3030
interface.
3131
@@ -35,7 +35,7 @@
3535
figures can optionally be saved to PNG images as well. The executables
3636
for all applications must be located on your :envvar:`PATH`.
3737
38-
Rc parameters that control the behavior of the pgf backend:
38+
`.rcParams` that control the behavior of the pgf backend:
3939
4040
================= =====================================================
4141
Parameter Documentation
@@ -61,7 +61,8 @@
6161
Multi-Page PDF Files
6262
====================
6363
64-
The pgf backend also supports multipage pdf files using ``PdfPages``
64+
The pgf backend also supports multipage pdf files using
65+
`~.backend_pgf.PdfPages`
6566
6667
.. code-block:: python
6768
@@ -83,16 +84,16 @@
8384
==================
8485
8586
The fonts used for obtaining the size of text elements or when compiling
86-
figures to PDF are usually defined in thematplotlib rc parameters. You can
87-
also use theLaTeX default Computer Modern fonts by clearing the lists for
88-
``font.serif``, ``font.sans-serif`` or``font.monospace``. Please note that the
89-
glyphcoverage of these fonts is very limited. If you want to keep the Computer
90-
Modern font face but require extendedunicode support, consider installing the
87+
figures to PDF are usually defined in the`.rcParams`. You can also use the
88+
LaTeX default Computer Modern fonts by clearing the lists for :rc:`font.serif`,
89+
:rc:`font.sans-serif` or:rc:`font.monospace`. Please note that the glyph
90+
coverage of these fonts is very limited. If you want to keep the Computer
91+
Modern font face but require extendedUnicode support, consider installing the
9192
`Computer Modern Unicode`__ fonts *CMU Serif*, *CMU Sans Serif*, etc.
9293
9394
__ https://sourceforge.net/projects/cm-unicode/
9495
95-
When saving to ``.pgf``, the font configurationmatplotlib used for the
96+
When saving to ``.pgf``, the font configurationMatplotlib used for the
9697
layout of the figure is included in the header of the text file.
9798
9899
.. literalinclude:: ../../gallery/userdemo/pgf_fonts.py
@@ -105,10 +106,10 @@
105106
===============
106107
107108
Full customization is possible by adding your own commands to the preamble.
108-
Usethe ``pgf.preamble`` parameter if you want to configure the math fonts,
109+
Use:rc:`pgf.preamble` if you want to configure the math fonts,
109110
using ``unicode-math`` for example, or for loading additional packages. Also,
110111
if you want to do the font configuration yourself instead of using the fonts
111-
specified in the rc parameters, make sure to disable``pgf.rcfonts``.
112+
specified in the rc parameters, make sure to disable:rc:`pgf.rcfonts`.
112113
113114
.. only:: html
114115
@@ -126,10 +127,10 @@
126127
Choosing the TeX system
127128
=======================
128129
129-
The TeX system to be used bymatplotlib is chosen bythe ``pgf.texsystem``
130-
parameter.Possible values are ``'xelatex'`` (default), ``'lualatex'`` and
131-
``'pdflatex'``.Please note that when selecting pdflatex the fonts and
132-
unicode handling mustbe configured in the preamble.
130+
The TeX system to be used byMatplotlib is chosen by:rc:`pgf.texsystem`.
131+
Possible values are ``'xelatex'`` (default), ``'lualatex'`` and ``'pdflatex'``.
132+
Please note that when selecting pdflatex, the fonts and Unicode handling must
133+
be configured in the preamble.
133134
134135
.. literalinclude:: ../../gallery/userdemo/pgf_texsystem.py
135136
:end-before: plt.savefig
@@ -162,7 +163,7 @@
162163
that your LaTeX syntax is valid and that you are using raw strings
163164
if necessary to avoid unintended escape sequences.
164165
165-
*The ``pgf.preamble`` rc setting provides lots of flexibility, and lots of
166+
*:rc:`pgf.preamble` provides lots of flexibility, and lots of
166167
ways to cause problems. When experiencing problems, try to minimalize or
167168
disable the custom preamble.
168169
@@ -176,10 +177,10 @@
176177
177178
__ http://tex.stackexchange.com/questions/43642
178179
179-
* If the font configuration used bymatplotlib differs from the font setting
180+
* If the font configuration used byMatplotlib differs from the font setting
180181
in yout LaTeX document, the alignment of text elements in imported figures
181182
may be off. Check the header of your ``.pgf`` file if you are unsure about
182-
the fontsmatplotlib used for the layout.
183+
the fontsMatplotlib used for the layout.
183184
184185
* Vector images and hence ``.pgf`` files can become bloated if there are a lot
185186
of objects in the graph. This can be the case for image processing or very

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp