Skip to content

Commit a34c859

Browse files
authored
Merge pull request matplotlib#8065 from dstansby/doc-accented-text
[MRG+1] Clean up and move accented text example
2 parents db9e631 + a14b453 commit a34c859

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

examples/pylab_examples/accented_text.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

examples/tests/backend_driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
]
9292

9393
files['text_labels_and_annotations'] = [
94+
'accented_text.py',
9495
'text_demo_fontdict.py',
9596
'unicode_demo.py',
9697
]
@@ -109,7 +110,6 @@
109110
]
110111

111112
files['pylab'] = [
112-
'accented_text.py',
113113
'alignment_test.py',
114114
'annotation_demo.py',
115115
'annotation_demo.py',
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# -*- coding: utf-8 -*-
2+
r"""
3+
=================================
4+
Using accented text in matplotlib
5+
=================================
6+
7+
Matplotlib supports accented characters via TeX mathtext or unicode.
8+
9+
Using mathtext, the following accents are provided: \hat, \breve, \grave, \bar,
10+
\acute, \tilde, \vec, \dot, \ddot. All of them have the same syntax,
11+
e.g., to make an overbar you do \bar{o} or to make an o umlaut you do
12+
\ddot{o}. The shortcuts are also provided, e.g.,: \"o \'e \`e \~n \.x
13+
\^y
14+
"""
15+
from __future__ import unicode_literals
16+
import matplotlib.pyplot as plt
17+
18+
# Mathtext demo
19+
fig, ax = plt.subplots()
20+
ax.plot(range(10))
21+
ax.set_title(r'$\ddot{o}\acute{e}\grave{e}\hat{O}'
22+
r'\breve{i}\bar{A}\tilde{n}\vec{q}$', fontsize=20)
23+
24+
# Shorthand is also supported and curly braces are optional
25+
ax.set_xlabel(r"""$\"o\ddot o \'e\`e\~n\.x\^y$""", fontsize=20)
26+
ax.text(4, 0.5, r"$F=m\ddot{x}$")
27+
fig.tight_layout()
28+
29+
# Unicode demo
30+
fig, ax = plt.subplots()
31+
ax.set_title("GISCARD CHAHUTÉ À L'ASSEMBLÉE")
32+
ax.set_xlabel("LE COUP DE DÉ DE DE GAULLE")
33+
ax.set_ylabel('André was here!')
34+
ax.text(0.2, 0.8, 'Institut für Festkörperphysik', rotation=45)
35+
ax.text(0.4, 0.2, 'AVA (check kerning)')
36+
37+
plt.show()

examples/text_labels_and_annotations/unicode_demo.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)