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

Skip to content

Commit 1812c99

Browse files
committed
Merge pull request matplotlib#4646 from ericmjl/mep12-tex_unicode_demo.py
MEP12 on tex_unicode_demo.py
2 parents 4c88c1f + d119526 commit 1812c99

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

examples/pylab_examples/tex_unicode_demo.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@
44
This demo is tex_demo.py modified to have unicode. See that file for
55
more information.
66
"""
7+
78
from __future__ import unicode_literals
8-
import matplotlib as mpl
9-
mpl.rcParams['text.usetex'] = True
10-
mpl.rcParams['text.latex.unicode'] = True
11-
from numpy import arange, cos, pi
12-
from matplotlib.pyplot import (figure, axes, plot, xlabel, ylabel, title,
13-
grid, savefig, show)
9+
import numpy as np
10+
import matplotlib
11+
matplotlib.rcParams['text.usetex'] = True
12+
matplotlib.rcParams['text.latex.unicode'] = True
13+
import matplotlib.pyplot as plt
1414

15-
figure(1, figsize=(6, 4))
16-
ax = axes([0.1, 0.1, 0.8, 0.7])
17-
t = arange(0.0, 1.0 + 0.01, 0.01)
18-
s = cos(2*2*pi*t) + 2
19-
plot(t, s)
15+
plt.figure(1, figsize=(6, 4))
16+
ax = plt.axes([0.1, 0.1, 0.8, 0.7])
17+
t = np.arange(0.0, 1.0 + 0.01, 0.01)
18+
s = np.cos(2*2*np.pi*t) + 2
19+
plt.plot(t, s)
2020

21-
xlabel(r'\textbf{time (s)}')
22-
ylabel(r'\textit{Velocity (\u00B0/sec)}', fontsize=16)
23-
title(r"\TeX\ is Number $\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!",
24-
fontsize=16, color='r')
25-
grid(True)
26-
show()
21+
plt.xlabel(r'\textbf{time (s)}')
22+
plt.ylabel(r'\textit{Velocity (\u00B0/sec)}', fontsize=16)
23+
plt.title(r"\TeX\ is Number \
24+
$\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!",
25+
fontsize=16, color='r')
26+
plt.grid(True)
27+
plt.show()

0 commit comments

Comments
 (0)