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

Update/cleanup pgf tutorial.#16281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
timhoffm merged 1 commit intomatplotlib:masterfromanntzer:pgfd
Jan 22, 2020
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 27 additions & 26 deletionstutorials/text/pgf.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,27 +5,27 @@

How to typeset text with the ``pgf`` backend in Matplotlib.

Using the ``pgf`` backend,matplotlib can export figures as pgf drawing
Using the ``pgf`` backend,Matplotlib can export figures as pgf drawing
commands that can be processed with pdflatex, xelatex or lualatex. XeLaTeX and
LuaLaTeX have fullunicode support and can use any font that is installed in
LuaLaTeX have fullUnicode support and can use any font that is installed in
the operating system, making use of advanced typographic features of OpenType,
AAT and Graphite. Pgf pictures created by ``plt.savefig('figure.pgf')``
can be embedded as raw commands in LaTeX documents. Figures can also be
directly compiled and saved to PDF with ``plt.savefig('figure.pdf')`` by either
switching to the backend

.. code-block:: python
directly compiled and saved to PDF with ``plt.savefig('figure.pdf')`` by
switching the backend ::

matplotlib.use('pgf')

orregistering it for handling pdf output
orby explicitly requesting the use of the ``pgf`` backend ::

.. code-block:: python
plt.savefig('figure.pdf', backend='pgf')

or by registering it for handling pdf output ::

from matplotlib.backends.backend_pgf import FigureCanvasPgf
matplotlib.backend_bases.register_backend('pdf', FigureCanvasPgf)

Thesecond method allows you to keep using regular interactive backends and to
Thelast method allows you to keep using regular interactive backends and to
save xelatex, lualatex or pdflatex compiled PDF files from the graphical user
interface.

Expand All@@ -35,7 +35,7 @@
figures can optionally be saved to PNG images as well. The executables
for all applications must be located on your :envvar:`PATH`.

Rc parameters that control the behavior of the pgf backend:
`.rcParams` that control the behavior of the pgf backend:

================= =====================================================
Parameter Documentation
Expand All@@ -61,7 +61,8 @@
Multi-Page PDF Files
====================

The pgf backend also supports multipage pdf files using ``PdfPages``
The pgf backend also supports multipage pdf files using
`~.backend_pgf.PdfPages`

.. code-block:: python

Expand All@@ -83,16 +84,16 @@
==================

The fonts used for obtaining the size of text elements or when compiling
figures to PDF are usually defined in thematplotlib rc parameters. You can
also use theLaTeX default Computer Modern fonts by clearing the lists for
``font.serif``, ``font.sans-serif`` or``font.monospace``. Please note that the
glyphcoverage of these fonts is very limited. If you want to keep the Computer
Modern font face but require extendedunicode support, consider installing the
figures to PDF are usually defined in the`.rcParams`. You can also use the
LaTeX default Computer Modern fonts by clearing the lists for :rc:`font.serif`,
:rc:`font.sans-serif` or:rc:`font.monospace`. Please note that the glyph
coverage of these fonts is very limited. If you want to keep the Computer
Modern font face but require extendedUnicode support, consider installing the
`Computer Modern Unicode`__ fonts *CMU Serif*, *CMU Sans Serif*, etc.

__ https://sourceforge.net/projects/cm-unicode/

When saving to ``.pgf``, the font configurationmatplotlib used for the
When saving to ``.pgf``, the font configurationMatplotlib used for the
layout of the figure is included in the header of the text file.

.. literalinclude:: ../../gallery/userdemo/pgf_fonts.py
Expand All@@ -105,10 +106,10 @@
===============

Full customization is possible by adding your own commands to the preamble.
Usethe ``pgf.preamble`` parameter if you want to configure the math fonts,
Use:rc:`pgf.preamble` if you want to configure the math fonts,
using ``unicode-math`` for example, or for loading additional packages. Also,
if you want to do the font configuration yourself instead of using the fonts
specified in the rc parameters, make sure to disable``pgf.rcfonts``.
specified in the rc parameters, make sure to disable:rc:`pgf.rcfonts`.

.. only:: html

Expand All@@ -126,10 +127,10 @@
Choosing the TeX system
=======================

The TeX system to be used bymatplotlib is chosen bythe ``pgf.texsystem``
parameter.Possible values are ``'xelatex'`` (default), ``'lualatex'`` and
``'pdflatex'``.Please note that when selecting pdflatex the fonts and
unicode handling mustbe configured in the preamble.
The TeX system to be used byMatplotlib is chosen by:rc:`pgf.texsystem`.
Possible values are ``'xelatex'`` (default), ``'lualatex'`` and ``'pdflatex'``.
Please note that when selecting pdflatex, the fonts and Unicode handling must
be configured in the preamble.

.. literalinclude:: ../../gallery/userdemo/pgf_texsystem.py
:end-before: plt.savefig
Expand DownExpand Up@@ -162,7 +163,7 @@
that your LaTeX syntax is valid and that you are using raw strings
if necessary to avoid unintended escape sequences.

*The ``pgf.preamble`` rc setting provides lots of flexibility, and lots of
*:rc:`pgf.preamble` provides lots of flexibility, and lots of
ways to cause problems. When experiencing problems, try to minimalize or
disable the custom preamble.

Expand All@@ -176,10 +177,10 @@

__ http://tex.stackexchange.com/questions/43642

* If the font configuration used bymatplotlib differs from the font setting
* If the font configuration used byMatplotlib differs from the font setting
in yout LaTeX document, the alignment of text elements in imported figures
may be off. Check the header of your ``.pgf`` file if you are unsure about
the fontsmatplotlib used for the layout.
the fontsMatplotlib used for the layout.

* Vector images and hence ``.pgf`` files can become bloated if there are a lot
of objects in the graph. This can be the case for image processing or very
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp