|
13 | 13 | ~/.tex.cache
|
14 | 14 |
|
15 | 15 | """
|
| 16 | +from __future__ import unicode_literals |
16 | 17 | import numpy as np
|
| 18 | +import matplotlib |
| 19 | +matplotlib.rcParams['text.usetex'] = True |
| 20 | +matplotlib.rcParams['text.latex.unicode'] = True |
17 | 21 | import matplotlib.pyplot as plt
|
18 | 22 |
|
19 | 23 |
|
20 |
| -plt.rc('text', usetex=True) |
21 | 24 | plt.rc('font', family='serif')
|
22 | 25 | plt.figure(1, figsize=(6, 4))
|
23 | 26 | ax = plt.axes([0.1, 0.1, 0.8, 0.7])
|
|
27 | 30 |
|
28 | 31 | plt.xlabel(r'\textbf{time (s)}')
|
29 | 32 | plt.ylabel(r'\textit{voltage (mV)}', fontsize=16)
|
30 |
| -plt.title(r"\TeX\ is Number $\displaystyle\sum_{n=1}^\infty" |
31 |
| - r"\frac{-e^{i\pi}}{2^n}$!", fontsize=16, color='r') |
| 33 | +plt.title(r'\TeX\ is Number $\displaystyle\sum_{n=1}^\infty' |
| 34 | + r'\frac{-e^{i\pi}}{2^n}$!', fontsize=16, color='r') |
32 | 35 | plt.grid(True)
|
33 | 36 | plt.savefig('tex_demo')
|
34 | 37 | plt.show()
|
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +plt.figure(2, figsize=(6, 4)) |
| 42 | +ax = plt.axes([0.1, 0.1, 0.8, 0.7]) |
| 43 | +t = np.arange(0.0, 1.0 + 0.01, 0.01) |
| 44 | +s = np.cos(2*2*np.pi*t) + 2 |
| 45 | +plt.plot(t, s) |
| 46 | + |
| 47 | +plt.xlabel(r'\textbf{time (s)}') |
| 48 | +plt.ylabel('\\textit{Velocity (\u00B0/sec)}', fontsize=16) |
| 49 | +plt.title(r'\TeX\ is Number $\displaystyle\sum_{n=1}^\infty' |
| 50 | + r'\frac{-e^{i\pi}}{2^n}$!', fontsize=16, color='r') |
| 51 | +plt.grid(True) |
| 52 | +plt.show() |
0 commit comments