|
3 | 3 | You can control the axis tick and grid properties
|
4 | 4 | """
|
5 | 5 |
|
6 |
| -from pylab import * |
| 6 | +import matplotlib.pyplot as plt |
| 7 | +import numpy as np |
7 | 8 |
|
8 |
| -t = arange(0.0, 2.0, 0.01) |
9 |
| -s = sin(2*pi*t) |
10 |
| -plot(t, s) |
11 |
| -grid(True) |
| 9 | +t = np.arange(0.0, 2.0, 0.01) |
| 10 | +s = np.sin(2*pi*t) |
| 11 | +plt.plot(t, s) |
| 12 | +plt.grid(True) |
12 | 13 |
|
13 | 14 | # MATLAB style
|
14 |
| -xticklines = getp(gca(), 'xticklines') |
15 |
| -yticklines = getp(gca(), 'yticklines') |
16 |
| -xgridlines = getp(gca(), 'xgridlines') |
17 |
| -ygridlines = getp(gca(), 'ygridlines') |
18 |
| -xticklabels = getp(gca(), 'xticklabels') |
19 |
| -yticklabels = getp(gca(), 'yticklabels') |
20 |
| - |
21 |
| -setp(xticklines, 'linewidth', 3) |
22 |
| -setp(yticklines, 'linewidth', 3) |
23 |
| -setp(xgridlines, 'linestyle', '-') |
24 |
| -setp(ygridlines, 'linestyle', '-') |
25 |
| -setp(yticklabels, 'color', 'r', fontsize='medium') |
26 |
| -setp(xticklabels, 'color', 'r', fontsize='medium') |
27 |
| - |
28 |
| - |
29 |
| -show() |
| 15 | +xticklines = plt.getp(plt.gca(), 'xticklines') |
| 16 | +yticklines = plt.getp(plt.gca(), 'yticklines') |
| 17 | +xgridlines = plt.getp(plt.gca(), 'xgridlines') |
| 18 | +ygridlines = plt.getp(plt.gca(), 'ygridlines') |
| 19 | +xticklabels = plt.getp(plt.gca(), 'xticklabels') |
| 20 | +yticklabels = plt.getp(plt.gca(), 'yticklabels') |
| 21 | + |
| 22 | +plt.setp(xticklines, 'linewidth', 3) |
| 23 | +plt.setp(yticklines, 'linewidth', 3) |
| 24 | +plt.setp(xgridlines, 'linestyle', '-') |
| 25 | +plt.setp(ygridlines, 'linestyle', '-') |
| 26 | +plt.setp(yticklabels, 'color', 'r', fontsize='medium') |
| 27 | +plt.setp(xticklabels, 'color', 'r', fontsize='medium') |
| 28 | + |
| 29 | + |
| 30 | +plt.show() |
30 | 31 |
|
31 | 32 |
|
32 | 33 | """
|
|
0 commit comments