|
4 | 4 | This demo is tex_demo.py modified to have unicode. See that file for
|
5 | 5 | more information.
|
6 | 6 | """
|
| 7 | + |
7 | 8 | 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 |
14 | 14 |
|
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) |
20 | 20 |
|
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