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

Skip to content

Commit 100e7e0

Browse files
committed
MEP12 on tex_unicode_demo.py
1 parent 0a5314a commit 100e7e0

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

examples/pylab_examples/tex_unicode_demo.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,27 @@
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 matplotlib
10+
matplotlib.rcParams['text.usetex'] = True
11+
matplotlib.rcParams['text.latex.unicode'] = True
12+
13+
import numpy as np
14+
# from numpy import arange, cos, pi
15+
# from matplotlib.pyplot import (figure, axes, plot, xlabel, ylabel, title,
16+
# grid, savefig, show)
17+
import matplotlib.pyplot as plt
1418

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)
19+
plt.figure(1, figsize=(6, 4))
20+
ax = plt.axes([0.1, 0.1, 0.8, 0.7])
21+
t = np.arange(0.0, 1.0 + 0.01, 0.01)
22+
s = np.cos(2*2*np.pi*t) + 2
23+
plt.plot(t, s)
2024

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}$!",
25+
plt.xlabel(r'\textbf{time (s)}')
26+
plt.ylabel(r'\textit{Velocity (\u00B0/sec)}', fontsize=16)
27+
plt.title(r"\TeX\ is Number $\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!",
2428
fontsize=16, color='r')
25-
grid(True)
26-
show()
29+
plt.grid(True)
30+
plt.show()

0 commit comments

Comments
 (0)