|
1 |
| -#!/usr/bin/env python |
2 | 1 | from matplotlib.font_manager import FontProperties
|
3 |
| -from pylab import * |
| 2 | +import matplotlib.pyplot as plt |
| 3 | +import numpy as np |
4 | 4 |
|
5 | 5 |
|
6 | 6 | def f(t):
|
7 |
| - s1 = cos(2*pi*t) |
8 |
| - e1 = exp(-t) |
9 |
| - return multiply(s1, e1) |
| 7 | + s1 = np.cos(2*np.pi*t) |
| 8 | + e1 = np.exp(-t) |
| 9 | + return s1 * e1 |
10 | 10 |
|
11 |
| -t1 = arange(0.0, 5.0, 0.1) |
12 |
| -t2 = arange(0.0, 5.0, 0.02) |
13 |
| -t3 = arange(0.0, 2.0, 0.01) |
| 11 | +t1 = np.arange(0.0, 5.0, 0.1) |
| 12 | +t2 = np.arange(0.0, 5.0, 0.02) |
| 13 | +t3 = np.arange(0.0, 2.0, 0.01) |
14 | 14 |
|
15 | 15 |
|
16 |
| -subplot(121) |
17 |
| -plot(t1, f(t1), 'bo', t2, f(t2), 'k') |
18 |
| -title('subplot 1') |
19 |
| -ylabel('Damped oscillation') |
20 |
| -suptitle('This is a somewhat long figure title', fontsize=16) |
| 16 | +plt.subplot(121) |
| 17 | +plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k') |
| 18 | +plt.title('subplot 1') |
| 19 | +plt.ylabel('Damped oscillation') |
| 20 | +plt.suptitle('This is a somewhat long figure title', fontsize=16) |
21 | 21 |
|
22 | 22 |
|
23 |
| -subplot(122) |
24 |
| -plot(t3, cos(2*pi*t3), 'r--') |
25 |
| -xlabel('time (s)') |
26 |
| -title('subplot 2') |
27 |
| -ylabel('Undamped') |
| 23 | +plt.subplot(122) |
| 24 | +plt.plot(t3, np.cos(2*np.pi*t3), 'r--') |
| 25 | +plt.xlabel('time (s)') |
| 26 | +plt.title('subplot 2') |
| 27 | +plt.ylabel('Undamped') |
28 | 28 |
|
29 |
| -show() |
| 29 | +plt.show() |
0 commit comments