Skip to content

Commit 512b553

Browse files
authored
Merge pull request #16579 from anntzer/usetex_fonteffects
Update usetex_fonteffects example.
2 parents 9a24fb7 + 43648ca commit 512b553

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

examples/text_labels_and_annotations/usetex_fonteffects.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,25 @@
44
==================
55
66
This script demonstrates that font effects specified in your pdftex.map
7-
are now supported in pdf usetex.
7+
are now supported in usetex mode.
88
"""
99

1010
import matplotlib.pyplot as plt
1111

1212

1313
def setfont(font):
14-
return r'\font\a %s at 14pt\a ' % font
14+
return rf'\font\a {font} at 14pt\a '
1515

1616

17+
fig = plt.figure()
1718
for y, font, text in zip(range(5),
1819
['ptmr8r', 'ptmri8r', 'ptmro8r',
1920
'ptmr8rn', 'ptmrr8re'],
2021
['Nimbus Roman No9 L ' + x for x in
2122
['', 'Italics (real italics for comparison)',
2223
'(slanted)', '(condensed)', '(extended)']]):
23-
plt.text(0, y, setfont(font) + text, usetex=True)
24+
fig.text(.1, 1 - (y + 1) / 6, setfont(font) + text, usetex=True)
2425

25-
plt.ylim(-1, 5)
26-
plt.xlim(-0.2, 0.6)
27-
plt.setp(plt.gca(), frame_on=False, xticks=(), yticks=())
28-
plt.title('Usetex font effects')
29-
plt.savefig('usetex_fonteffects.pdf')
26+
fig.suptitle('Usetex font effects')
27+
# Would also work if saving to pdf.
28+
plt.show()

0 commit comments

Comments
 (0)