Skip to content

Commit

Permalink
DOC minor fixes to plot_tex.py
Browse files Browse the repository at this point in the history
  • Loading branch information
NelleV authored and QuLogic committed May 29, 2017
1 parent a0f91fa commit 7802749
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 75 deletions.
2 changes: 1 addition & 1 deletion doc/devel/documenting_mpl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ git. Please also add a line to the README in doc/pyplots for any additional
requirements necessary to generate a new figure. Once these steps have been
taken, these figures can be included in the usual way::

.. plot:: mpl_examples/pyplots/tex_unicode_demo.py
.. plot:: mpl_examples/text_labels_and_annotations/tex_demo.py
:include-source:

Examples
Expand Down
39 changes: 0 additions & 39 deletions examples/pyplots/tex_demo.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
========
Tex Demo
========
=================================
Rendering math equation using TeX
=================================
You can use TeX to render all of your matplotlib text if the rc
parameter text.usetex is set. This works currently on the agg and ps
Expand All @@ -12,6 +12,8 @@
time, the run may be silent, as a lot of the information is cached in
~/.tex.cache
Notice how the the label for the y axis is provided using unicode!
"""
from __future__ import unicode_literals
import numpy as np
Expand All @@ -21,32 +23,17 @@
import matplotlib.pyplot as plt


plt.rc('font', family='serif')
plt.figure(1, figsize=(6, 4))
ax = plt.axes([0.1, 0.1, 0.8, 0.7])
t = np.linspace(0.0, 1.0, 100)
s = np.cos(4 * np.pi * t) + 2
plt.plot(t, s)

plt.xlabel(r'\textbf{time (s)}')
plt.ylabel(r'\textit{voltage (mV)}', fontsize=16)
plt.title(r'\TeX\ is Number $\displaystyle\sum_{n=1}^\infty'
r'\frac{-e^{i\pi}}{2^n}$!', fontsize=16, color='r')
plt.grid(True)
plt.savefig('tex_demo')
plt.show()



plt.figure(2, figsize=(6, 4))
ax = plt.axes([0.1, 0.1, 0.8, 0.7])
t = np.arange(0.0, 1.0 + 0.01, 0.01)
s = np.cos(2*2*np.pi*t) + 2
plt.plot(t, s)

plt.xlabel(r'\textbf{time (s)}')
plt.ylabel('\\textit{Velocity (\u00B0/sec)}', fontsize=16)
plt.title(r'\TeX\ is Number $\displaystyle\sum_{n=1}^\infty'
r'\frac{-e^{i\pi}}{2^n}$!', fontsize=16, color='r')
plt.grid(True)
fig, ax = plt.subplots(figsize=(6, 4), tight_layout=True)
ax.plot(t, s)

ax.set_xlabel(r'\textbf{time (s)}')
ax.set_ylabel('\\textit{Velocity (\u00B0/sec)}')
ax.set_title(r'\TeX\ is Number $\displaystyle\sum_{n=1}^\infty'
r'\frac{-e^{i\pi}}{2^n}$!')
plt.show()
1 change: 0 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ pep8ignore =
*examples/pyplots/pyplot_mathtext.py E231
*examples/pyplots/pyplot_simple.py E231
*examples/pyplots/pyplot_two_subplots.py E302
*examples/pyplots/tex_demo.py E231
*examples/pyplots/text_commands.py E231
*examples/pyplots/text_layout.py E231
*examples/pyplots/whats_new_1_subplot3d.py W391
Expand Down
4 changes: 2 additions & 2 deletions tutorials/01_introductory/sample_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,8 @@
powerful, sometimes you need TeX. Matplotlib supports external TeX
rendering of strings with the *usetex* option.
.. figure:: ../../gallery/pyplots/images/sphx_glr_tex_demo_001.png
:target: ../../gallery/pyplots/tex_demo.html
.. figure:: ../../gallery/text_labels_and_annotations/images/sphx_glr_tex_demo_001.png
:target: ../../gallery/text_labels_and_annotations/tex_demo.html
:align: center
:scale: 50
Expand Down
15 changes: 8 additions & 7 deletions tutorials/text/usetex.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
Here is the standard example, `tex_demo.py`:
.. figure:: ../../gallery/pyplots/images/sphx_glr_tex_demo_001.png
:target: ../../gallery/pyplots/tex_demo.html
.. figure:: ../../gallery/text_labels_and_annotations/images/sphx_glr_tex_demo_001.png
:target: ../../gallery/text_labels_and_annotations/tex_demo.html
:align: center
:scale: 50
Tex Demo
TeX Demo
Note that display math mode (``$$ e=mc^2 $$``) is not supported, but adding the
command ``\displaystyle``, as in `tex_demo.py`, will produce the same
Expand All @@ -76,15 +76,16 @@
usetex with unicode
===================
It is also possible to use unicode strings with the LaTeX text manager, here is
an example taken from `tex_unicode_demo.py`:
an example taken from `tex_demo.py`. The axis labels include Unicode text:
.. figure:: ../../gallery/pylab_examples/images/sphx_glr_tex_unicode_demo_001.png
:target: ../../gallery/pylab_examples/tex_unicode_demo.html
.. figure:: ../../gallery/text_labels_and_annotations/images/sphx_glr_tex_demo_001.png
:target: ../../gallery/text_labels_and_annotations/tex_demo.html
:align: center
:scale: 50
Tex Unicode Demo
TeX Unicode Demo
.. _usetex-postscript:
Expand Down

0 comments on commit 7802749

Please sign in to comment.