Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cc2c508

Browse files
authored
Merge pull request #8199 from delftswa2017/tex_gallery
merged the tex_X.py files into a single file tex.py
2 parents 9b9c24c + 864138f commit cc2c508

File tree

8 files changed

+46
-114
lines changed

8 files changed

+46
-114
lines changed

doc/devel/documenting_mpl.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ git. Please also add a line to the README in doc/pyplots for any additional
352352
requirements necessary to generate a new figure. Once these steps have been
353353
taken, these figures can be included in the usual way::
354354

355-
.. plot:: mpl_examples/pyplots/tex_unicode_demo.py
355+
.. plot:: mpl_examples/text_labels_and_annotations/tex_demo.py
356356
:include-source:
357357

358358
Examples

examples/pylab_examples/tex_demo.py

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

examples/pylab_examples/tex_unicode_demo.py

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

examples/pyplots/tex_demo.py

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
=================================
3+
Rendering math equation using TeX
4+
=================================
5+
6+
You can use TeX to render all of your matplotlib text if the rc
7+
parameter text.usetex is set. This works currently on the agg and ps
8+
backends, and requires that you have tex and the other dependencies
9+
described at http://matplotlib.org/users/usetex.html
10+
properly installed on your system. The first time you run a script
11+
you will see a lot of output from tex and associated tools. The next
12+
time, the run may be silent, as a lot of the information is cached.
13+
14+
Notice how the the label for the y axis is provided using unicode!
15+
16+
"""
17+
from __future__ import unicode_literals
18+
import numpy as np
19+
import matplotlib
20+
matplotlib.rcParams['text.usetex'] = True
21+
matplotlib.rcParams['text.latex.unicode'] = True
22+
import matplotlib.pyplot as plt
23+
24+
25+
t = np.linspace(0.0, 1.0, 100)
26+
s = np.cos(4 * np.pi * t) + 2
27+
28+
fig, ax = plt.subplots(figsize=(6, 4), tight_layout=True)
29+
ax.plot(t, s)
30+
31+
ax.set_xlabel(r'\textbf{time (s)}')
32+
ax.set_ylabel('\\textit{Velocity (\N{DEGREE SIGN}/sec)}', fontsize=16)
33+
ax.set_title(r'\TeX\ is Number $\displaystyle\sum_{n=1}^\infty'
34+
r'\frac{-e^{i\pi}}{2^n}$!', fontsize=16, color='r')
35+
plt.show()

pytest.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ pep8ignore =
129129
*examples/pyplots/pyplot_mathtext.py E231
130130
*examples/pyplots/pyplot_simple.py E231
131131
*examples/pyplots/pyplot_two_subplots.py E302
132-
*examples/pyplots/tex_demo.py E231
133132
*examples/pyplots/text_commands.py E231
134133
*examples/pyplots/text_layout.py E231
135134
*examples/pyplots/whats_new_1_subplot3d.py W391

tutorials/01_introductory/sample_plots.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@
340340
powerful, sometimes you need TeX. Matplotlib supports external TeX
341341
rendering of strings with the *usetex* option.
342342
343-
.. figure:: ../../gallery/pyplots/images/sphx_glr_tex_demo_001.png
344-
:target: ../../gallery/pyplots/tex_demo.html
343+
.. figure:: ../../gallery/text_labels_and_annotations/images/sphx_glr_tex_demo_001.png
344+
:target: ../../gallery/text_labels_and_annotations/tex_demo.html
345345
:align: center
346346
:scale: 50
347347

tutorials/text/usetex.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@
5353
5454
Here is the standard example, `tex_demo.py`:
5555
56-
.. figure:: ../../gallery/pyplots/images/sphx_glr_tex_demo_001.png
57-
:target: ../../gallery/pyplots/tex_demo.html
56+
.. figure:: ../../gallery/text_labels_and_annotations/images/sphx_glr_tex_demo_001.png
57+
:target: ../../gallery/text_labels_and_annotations/tex_demo.html
5858
:align: center
5959
:scale: 50
6060
61-
Tex Demo
61+
TeX Demo
6262
6363
Note that display math mode (``$$ e=mc^2 $$``) is not supported, but adding the
6464
command ``\displaystyle``, as in `tex_demo.py`, will produce the same
@@ -76,15 +76,16 @@
7676
7777
usetex with unicode
7878
===================
79+
7980
It is also possible to use unicode strings with the LaTeX text manager, here is
80-
an example taken from `tex_unicode_demo.py`:
81+
an example taken from `tex_demo.py`. The axis labels include Unicode text:
8182
82-
.. figure:: ../../gallery/pylab_examples/images/sphx_glr_tex_unicode_demo_001.png
83-
:target: ../../gallery/pylab_examples/tex_unicode_demo.html
83+
.. figure:: ../../gallery/text_labels_and_annotations/images/sphx_glr_tex_demo_001.png
84+
:target: ../../gallery/text_labels_and_annotations/tex_demo.html
8485
:align: center
8586
:scale: 50
8687
87-
Tex Unicode Demo
88+
TeX Unicode Demo
8889
8990
.. _usetex-postscript:
9091

0 commit comments

Comments
 (0)