8000 DOC minor fixes to plot_tex.py · matplotlib/matplotlib@7802749 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7802749

Browse files
NelleVQuLogic
authored andcommitted
DOC minor fixes to plot_tex.py
1 parent a0f91fa commit 7802749

File tree

6 files changed

+23
-75
lines changed

6 files changed

+23
-75
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/pyplots/tex_demo.py

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
2-
========
3-
Tex Demo
4-
========
2+
=================================
3+
Rendering math equation using TeX
4+
=================================
55
66
You can use TeX to render all of your matplotlib text if the rc
77
parameter text.usetex is set. This works currently on the agg and ps
@@ -12,6 +12,8 @@
1212
time, the run may be silent, as a lot of the information is cached in
1313
~/.tex.cache
1414
15+
Notice how the the label for the y axis is provided using unicode!
16+
1517
"""
1618
from __future__ import unicode_literals
1719
import numpy as np
@@ -21,32 +23,17 @@
2123
import matplotlib.pyplot as plt
2224

2325

24-
plt.rc('font', family='serif')
25-
plt.figure(1, figsize=(6, 4))
26-
ax = plt.axes([0.1, 0.1, 0.8, 0.7])
2726
t = np.linspace(0.0, 1.0, 100)
2827
s = np.cos(4 * np.pi * t) + 2
29-
plt.plot(t, s)
30-
31-
plt.xlabel(r'\textbf{time (s)}')
32-
plt.ylabel(r'\textit{voltage (mV)}', fontsize=16)
33-
plt.title(r'\TeX\ is Number $\displaystyle\sum_{n=1}^\infty'
34-
r'\frac{-e^{i\pi}}{2^n}$!', fontsize=16, color='r')
35-
plt.grid(True)
36-
plt.savefig('tex_demo')
37-
plt.show()
38-
3928

40-
41-
plt.figure(2, figsize=(6, 4))
42-
ax = plt.axes([0.1, 0.1, 0.8, 0.7])
4329
t = np.arange(0.0, 1.0 + 0.01, 0.01)
4430
s = np.cos(2*2*np.pi*t) + 2
45-
plt.plot(t, s)
4631

47-
plt.xlabel(r'\textbf{time (s)}')
48-
plt.ylabel('\\textit{Velocity (\u00B0/sec)}', fontsize=16)
49-
plt.title(r'\TeX\ is Number $\displaystyle\sum_{n=1}^\infty'
50-
r'\frac{-e^{i\pi}}{2^n}$!', fontsize=16, color='r')
51-
plt.grid(True)
32+
fig, ax = plt.subplots(figsize=(6, 4), tight_layout=True)
33+
ax.plot(t, s)
34+
35+
ax.set_xlabel(r'\textbf{time (s)}')
36+
ax.set_ylabel('\\textit{Velocity (\u00B0/sec)}')
37+
ax.set_title(r'\TeX\ is Number $\displaystyle\sum_{n=1}^\infty'
38+
r'\frac{-e^{i\pi}}{2^n}$!')
5239
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 1E79 /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)
0