8000 Cleanup pgf examples by QuLogic · Pull Request #18685 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Cleanup pgf examples #18685

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
29 changes: 17 additions & 12 deletions examples/userdemo/pgf_fonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@
import matplotlib.pyplot as plt
plt.rcParams.update({
"font.family": "serif",
"font.serif": [], # use latex default serif font
"font.sans-serif": ["DejaVu Sans"], # use a specific sans-serif font
# Use LaTeX default serif font.
"font.serif": [],
Comment on lines +11 to +12
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, this fallback does not work for me; it decides to use 'DejaVu Sans' before even getting to pgf/LaTeX. I'm not sure how to fix it.

10000

# Use specific cursive fonts.
"font.cursive": ["Comic Neue", "Comic Sans MS"],
})

plt.figure(figsize=(4.5, 2.5))
plt.plot(range(5))
plt.text(0.5, 3., "serif")
plt.text(0.5, 2., "monospace", family="monospace")
plt.text(2.5, 2., "sans-serif", family="sans-serif")
plt.text(2.5, 1., "comic sans", family="Comic Sans MS")
plt.xlabel("µ is not $\\mu$")
plt.tight_layout(.5)
fig, ax = plt.subplots(figsize=(4.5, 2.5))

plt.savefig("pgf_fonts.pdf")
plt.savefig("pgf_fonts.png")
ax.plot(range(5))

ax.text(0.5, 3., "serif")
ax.text(0.5, 2., "monospace", family="monospace")
ax.text(2.5, 2., "sans-serif", family="DejaVu Sans") # Use specific sans font.
ax.text(2.5, 1., "comic", family="cursive")
ax.set_xlabel("µ is not $\\mu$")

fig.tight_layout(pad=.5)

fig.savefig("pgf_fonts.pdf")
fig.savefig("pgf_fonts.png")
19 changes: 11 additions & 8 deletions examples/userdemo/pgf_preamble_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
])
})

plt.figure(figsize=(4.5, 2.5))
plt.plot(range(5))
plt.xlabel("unicode text: я, ψ, €, ü")
plt.ylabel(r"\url{https://matplotlib.org}")
plt.legend(["unicode math: $λ=∑_i^∞ μ_i^2$"])
plt.tight_layout(.5)
fig, ax = plt.subplots(figsize=(4.5, 2.5))

plt.savefig("pgf_preamble.pdf")
plt.savefig("pgf_preamble.png")
ax.plot(range(5))

ax.set_xlabel("unicode text: я, ψ, €, ü")
ax.set_ylabel(r"\url{https://matplotlib.org}")
ax.legend(["unicode math: $λ=∑_i^∞ μ_i^2$"])

fig.tight_layout(pad=.5)

fig.savefig("pgf_preamble.pdf")
fig.savefig("pgf_preamble.png")
21 changes: 12 additions & 9 deletions examples/userdemo/pgf_texsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
]),
})

plt.figure(figsize=(4.5, 2.5))
plt.plot(range(5) F4C1 )
plt.text(0.5, 3., "serif", family="serif")
plt.text(0.5, 2., "monospace", family="monospace")
plt.text(2.5, 2., "sans-serif", family="sans-serif")
plt.xlabel(r"µ is not $\mu$")
plt.tight_layout(.5)
fig, ax = plt.subplots(figsize=(4.5, 2.5))

plt.savefig("pgf_texsystem.pdf")
plt.savefig("pgf_texsystem.png")
ax.plot(range(5))

ax.text(0.5, 3., "serif", family="serif")
ax.text(0.5, 2., "monospace", family="monospace")
ax.text(2.5, 2., "sans-serif", family="sans-serif")
ax.set_xlabel(r"µ is not $\mu$")

fig.tight_layout(pad=.5)

fig.savefig("pgf_texsystem.pdf")
fig.savefig("pgf_texsystem.png")
6 changes: 3 additions & 3 deletions tutorials/text/pgf.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
layout of the figure is included in the header of the text file.

.. literalinclude:: ../../gallery/userdemo/pgf_fonts.py
:end-before: plt.savefig
:end-before: fig.savefig


.. _pgf-preamble:
Expand All @@ -114,7 +114,7 @@
.. only:: html

.. literalinclude:: ../../gallery/userdemo/pgf_preamble_sgskip.py
:end-before: plt.savefig
:end-before: fig.savefig

.. only:: latex

Expand All @@ -133,7 +133,7 @@
be configured in the preamble.

.. literalinclude:: ../../gallery/userdemo/pgf_texsystem.py
:end-before: plt.savefig
:end-before: fig.savefig


.. _pgf-troubleshooting:
Expand Down
0