Skip to content

merged the tex_X.py files into a single file tex.py #8199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
34 changes: 0 additions & 34 deletions examples/pylab_examples/tex_demo.py

This file was deleted.

30 changes: 0 additions & 30 deletions examples/pylab_examples/tex_unicode_demo.py

This file was deleted.

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

This file was deleted.

35 changes: 35 additions & 0 deletions examples/text_labels_and_annotations/tex_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
=================================
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
backends, and requires that you have tex and the other dependencies
described at http://matplotlib.org/users/usetex.html
properly installed on your system. The first time you run a script
you will see a lot of output from tex and associated tools. The next
time, the run may be silent, as a lot of the information is cached.

Notice how the the label for the y axis is provided using unicode!

"""
from __future__ import unicode_literals
import numpy as np
import matplotlib
matplotlib.rcParams['text.usetex'] = True
matplotlib.rcParams['text.latex.unicode'] = True
import matplotlib.pyplot as plt


t = np.linspace(0.0, 1.0, 100)
s = np.cos(4 * np.pi * t) + 2

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 (\N{DEGREE SIGN}/sec)}', fontsize=16)
ax.set_title(r'\TeX\ is Number $\displaystyle\sum_{n=1}^\infty'
r'\frac{-e^{i\pi}}{2^n}$!', fontsize=16, color='r')
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