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

Appearance settings

Commit 648bd37

Browse filesBrowse files
committed
DOC: Convert pgf examples to OO style.
1 parent 0bdc2ab commit 648bd37
Copy full SHA for 648bd37

File tree

Expand file treeCollapse file tree

4 files changed

+39
-30
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+39
-30
lines changed

‎examples/userdemo/pgf_fonts.py

Copy file name to clipboardExpand all lines: examples/userdemo/pgf_fonts.py
+13-10Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@
1212
"font.sans-serif": ["DejaVu Sans"], # use a specific sans-serif font
1313
})
1414

15-
plt.figure(figsize=(4.5, 2.5))
16-
plt.plot(range(5))
17-
plt.text(0.5, 3., "serif")
18-
plt.text(0.5, 2., "monospace", family="monospace")
19-
plt.text(2.5, 2., "sans-serif", family="sans-serif")
20-
plt.text(2.5, 1., "comic sans", family="Comic Sans MS")
21-
plt.xlabel("µ is not $\\mu$")
22-
plt.tight_layout(.5)
15+
fig, ax = plt.subplots(figsize=(4.5, 2.5))
2316

24-
plt.savefig("pgf_fonts.pdf")
25-
plt.savefig("pgf_fonts.png")
17+
ax.plot(range(5))
18+
19+
ax.text(0.5, 3., "serif")
20+
ax.text(0.5, 2., "monospace", family="monospace")
21+
ax.text(2.5, 2., "sans-serif", family="sans-serif")
22+
ax.text(2.5, 1., "comic sans", family="Comic Sans MS")
23+
ax.set_xlabel("µ is not $\\mu$")
24+
25+
fig.tight_layout(pad=.5)
26+
27+
fig.savefig("pgf_fonts.pdf")
28+
fig.savefig("pgf_fonts.png")

‎examples/userdemo/pgf_preamble_sgskip.py

Copy file name to clipboardExpand all lines: examples/userdemo/pgf_preamble_sgskip.py
+11-8Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
])
2020
})
2121

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

29-
plt.savefig("pgf_preamble.pdf")
30-
plt.savefig("pgf_preamble.png")
24+
ax.plot(range(5))
25+
26+
ax.set_xlabel("unicode text: я, ψ, €, ü")
27+
ax.set_ylabel(r"\url{https://matplotlib.org}")
28+
ax.legend(["unicode math: $λ=∑_i^∞ μ_i^2$"])
29+
30+
fig.tight_layout(pad=.5)
31+
32+
fig.savefig("pgf_preamble.pdf")
33+
fig.savefig("pgf_preamble.png")

‎examples/userdemo/pgf_texsystem.py

Copy file name to clipboardExpand all lines: examples/userdemo/pgf_texsystem.py
+12-9Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@
1515
]),
1616
})
1717

18-
plt.figure(figsize=(4.5, 2.5))
19-
plt.plot(range(5))
20-
plt.text(0.5, 3., "serif", family="serif")
21-
plt.text(0.5, 2., "monospace", family="monospace")
22-
plt.text(2.5, 2., "sans-serif", family="sans-serif")
23-
plt.xlabel(r"µ is not $\mu$")
24-
plt.tight_layout(.5)
18+
fig, ax = plt.subplots(figsize=(4.5, 2.5))
2519

26-
plt.savefig("pgf_texsystem.pdf")
27-
plt.savefig("pgf_texsystem.png")
20+
ax.plot(range(5))
21+
22+
ax.text(0.5, 3., "serif", family="serif")
23+
ax.text(0.5, 2., "monospace", family="monospace")
24+
ax.text(2.5, 2., "sans-serif", family="sans-serif")
25+
ax.set_xlabel(r"µ is not $\mu$")
26+
27+
fig.tight_layout(pad=.5)
28+
29+
fig.savefig("pgf_texsystem.pdf")
30+
fig.savefig("pgf_texsystem.png")

‎tutorials/text/pgf.py

Copy file name to clipboardExpand all lines: tutorials/text/pgf.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
layout of the figure is included in the header of the text file.
9898
9999
.. literalinclude:: ../../gallery/userdemo/pgf_fonts.py
100-
:end-before: plt.savefig
100+
:end-before: fig.savefig
101101
102102
103103
.. _pgf-preamble:
@@ -114,7 +114,7 @@
114114
.. only:: html
115115
116116
.. literalinclude:: ../../gallery/userdemo/pgf_preamble_sgskip.py
117-
:end-before: plt.savefig
117+
:end-before: fig.savefig
118118
119119
.. only:: latex
120120
@@ -133,7 +133,7 @@
133133
be configured in the preamble.
134134
135135
.. literalinclude:: ../../gallery/userdemo/pgf_texsystem.py
136-
:end-before: plt.savefig
136+
:end-before: fig.savefig
137137
138138
139139
.. _pgf-troubleshooting:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.