From 2665eabc5394ca5c521c2ba5e86bd791b3bcd9d3 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Sun, 12 Feb 2017 12:19:32 +0000 Subject: [PATCH 1/5] Clean up and move accented text example --- examples/tests/backend_driver.py | 2 +- .../accented_text.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) rename examples/{pylab_examples => text_labels_and_annotations}/accented_text.py (65%) diff --git a/examples/tests/backend_driver.py b/examples/tests/backend_driver.py index c8877fba2259..b64db8fff919 100755 --- a/examples/tests/backend_driver.py +++ b/examples/tests/backend_driver.py @@ -91,6 +91,7 @@ ] files['text_labels_and_annotations'] = [ + 'accented_text.py', 'text_demo_fontdict.py', 'unicode_demo.py', ] @@ -109,7 +110,6 @@ ] files['pylab'] = [ - 'accented_text.py', 'alignment_test.py', 'annotation_demo.py', 'annotation_demo.py', diff --git a/examples/pylab_examples/accented_text.py b/examples/text_labels_and_annotations/accented_text.py similarity index 65% rename from examples/pylab_examples/accented_text.py rename to examples/text_labels_and_annotations/accented_text.py index 16733a8060a4..1d718d2904e3 100644 --- a/examples/pylab_examples/accented_text.py +++ b/examples/text_labels_and_annotations/accented_text.py @@ -1,21 +1,24 @@ r""" -matplotlib supports accented characters via TeX mathtext +================================= +Using accented text in matplotlib +================================= +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) +plt.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's are optional plt.xlabel(r"""$\"o\ddot o \'e\`e\~n\.x\^y$""", fontsize=20) - plt.show() From 2a6bd58d7ff91d77f5b03eb7e52af183c7cff47a Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 16 Feb 2017 22:36:26 +0000 Subject: [PATCH 2/5] Merge unicode_demo into accented_text --- .../accented_text.py | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/examples/text_labels_and_annotations/accented_text.py b/examples/text_labels_and_annotations/accented_text.py index 1d718d2904e3..94ace5757e15 100644 --- a/examples/text_labels_and_annotations/accented_text.py +++ b/examples/text_labels_and_annotations/accented_text.py @@ -1,24 +1,36 @@ +# -*- coding: utf-8 -*- r""" ================================= Using accented text in matplotlib ================================= -Matplotlib supports accented characters via TeX mathtext. -The following accents are provided: \hat, \breve, \grave, \bar, +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 -plt.axes([0.1, 0.15, 0.8, 0.75]) -plt.plot(range(10)) +# 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) -plt.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's are optional +ax.set_xlabel(r"""$\"o\ddot o \'e\`e\~n\.x\^y$""", fontsize=20) +fig.tight_layout() -# shorthand is also supported and curly's are optional -plt.xlabel(r"""$\"o\ddot o \'e\`e\~n\.x\^y$""", fontsize=20) +# Unicode demo +fig, ax = plt.subplots() +ax.set_title('Développés et fabriqués') +ax.set_xlabel("réactivité nous permettent d'être sélectionnés et adoptés") +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() From b430281b438feaeab2deee2fb72d7897c5bf5809 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 16 Feb 2017 22:46:59 +0000 Subject: [PATCH 3/5] Remove unicode_demo --- .../text_labels_and_annotations/unicode_demo.py | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 examples/text_labels_and_annotations/unicode_demo.py diff --git a/examples/text_labels_and_annotations/unicode_demo.py b/examples/text_labels_and_annotations/unicode_demo.py deleted file mode 100644 index 5fc39bea0f4c..000000000000 --- a/examples/text_labels_and_annotations/unicode_demo.py +++ /dev/null @@ -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() From 1122dc5799619f9edad55807951e55d5c4c85ff7 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 17 Feb 2017 10:30:28 +0000 Subject: [PATCH 4/5] Update accented text sentences@ --- examples/text_labels_and_annotations/accented_text.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/text_labels_and_annotations/accented_text.py b/examples/text_labels_and_annotations/accented_text.py index 94ace5757e15..19f4d249305f 100644 --- a/examples/text_labels_and_annotations/accented_text.py +++ b/examples/text_labels_and_annotations/accented_text.py @@ -23,12 +23,13 @@ # Shorthand is also supported and curly's 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('Développés et fabriqués') -ax.set_xlabel("réactivité nous permettent d'être sélectionnés et adoptés") +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)') From a14b45369f370a1b32f7f78550494966c248a73b Mon Sep 17 00:00:00 2001 From: David Stansby Date: Tue, 21 Feb 2017 18:45:22 +0000 Subject: [PATCH 5/5] Curlies --> curly braces --- examples/text_labels_and_annotations/accented_text.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/text_labels_and_annotations/accented_text.py b/examples/text_labels_and_annotations/accented_text.py index 19f4d249305f..e121c429f7f5 100644 --- a/examples/text_labels_and_annotations/accented_text.py +++ b/examples/text_labels_and_annotations/accented_text.py @@ -21,7 +21,7 @@ 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's are optional +# 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()