Clean up and move accented text example #8065
Merged
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2665eab
Clean up and move accented text example
dstansby 2a6bd58
Merge unicode_demo into accented_text
dstansby b430281
Remove unicode_demo
dstansby 1122dc5
Update accented text sentences@
dstansby a14b453
Curlies --> curly braces
dstansby
Jump to file
No files or symbols found.
| @@ -1,21 +0,0 @@ | ||
| -r""" | ||
| -matplotlib supports accented characters via TeX mathtext | ||
| - | ||
| -The following accents are provided: \hat, \breve, \grave, \bar, | ||
| -\acute, \tilde, \vec, \dot, \ddot. All of them have the same syntax, | ||
| -e.g., to make an overbar you do \bar{o} or to make an o umlaut you do | ||
| -\ddot{o}. The shortcuts are also provided, e.g.,: \"o \'e \`e \~n \.x | ||
| -\^y | ||
| - | ||
| -""" | ||
| -import matplotlib.pyplot as plt | ||
| - | ||
| -plt.axes([0.1, 0.15, 0.8, 0.75]) | ||
| -plt.plot(range(10)) | ||
| - | ||
| -plt.title(r'$\ddot{o}\acute{e}\grave{e}\hat{O}\breve{i}\bar{A}\tilde{n}\vec{q}$', fontsize=20) | ||
| -# shorthand is also supported and curly's are optional | ||
| -plt.xlabel(r"""$\"o\ddot o \'e\`e\~n\.x\^y$""", fontsize=20) | ||
| - | ||
| - | ||
| -plt.show() |
| @@ -0,0 +1,37 @@ | ||
| +# -*- coding: utf-8 -*- | ||
| +r""" | ||
| +================================= | ||
| +Using accented text in matplotlib | ||
| +================================= | ||
| + | ||
| +Matplotlib supports accented characters via TeX mathtext or unicode. | ||
| + | ||
| +Using mathtext, the following accents are provided: \hat, \breve, \grave, \bar, | ||
| +\acute, \tilde, \vec, \dot, \ddot. All of them have the same syntax, | ||
| +e.g., to make an overbar you do \bar{o} or to make an o umlaut you do | ||
| +\ddot{o}. The shortcuts are also provided, e.g.,: \"o \'e \`e \~n \.x | ||
| +\^y | ||
| +""" | ||
| +from __future__ import unicode_literals | ||
| +import matplotlib.pyplot as plt | ||
| + | ||
| +# Mathtext demo | ||
| +fig, ax = plt.subplots() | ||
| +ax.plot(range(10)) | ||
| +ax.set_title(r'$\ddot{o}\acute{e}\grave{e}\hat{O}' | ||
| + r'\breve{i}\bar{A}\tilde{n}\vec{q}$', fontsize=20) | ||
| + | ||
| +# Shorthand is also supported and curly braces are optional | ||
| +ax.set_xlabel(r"""$\"o\ddot o \'e\`e\~n\.x\^y$""", fontsize=20) | ||
| +ax.text(4, 0.5, r"$F=m\ddot{x}$") | ||
| +fig.tight_layout() | ||
| + | ||
| +# Unicode demo | ||
| +fig, ax = plt.subplots() | ||
| +ax.set_title("GISCARD CHAHUTÉ À L'ASSEMBLÉE") | ||
| +ax.set_xlabel("LE COUP DE DÉ DE DE GAULLE") | ||
| +ax.set_ylabel('André was here!') | ||
| +ax.text(0.2, 0.8, 'Institut für Festkörperphysik', rotation=45) | ||
| +ax.text(0.4, 0.2, 'AVA (check kerning)') | ||
| + | ||
| +plt.show() |
| @@ -1,16 +0,0 @@ | ||
| -# -*- coding: utf-8 -*- | ||
| -""" | ||
| -Demo of unicode support in text and labels. | ||
| -""" | ||
| -from __future__ import unicode_literals | ||
| - | ||
| -import matplotlib.pyplot as plt | ||
| - | ||
| - | ||
| -plt.title('Développés et fabriqués') | ||
| -plt.xlabel("réactivité nous permettent d'être sélectionnés et adoptés") | ||
| -plt.ylabel('André was here!') | ||
| -plt.text(0.2, 0.8, 'Institut für Festkörperphysik', rotation=45) | ||
| -plt.text(0.4, 0.2, 'AVA (check kerning)') | ||
| - | ||
| -plt.show() |