|
1 |
| -#!/usr/bin/env python |
2 | 1 | """
|
3 | 2 | You can control the axis tick and grid properties
|
4 | 3 | """
|
|
7 | 6 | import numpy as np
|
8 | 7 |
|
9 | 8 | t = np.arange(0.0, 2.0, 0.01)
|
10 |
| -s = np.sin(2*np.pi*t) |
11 |
| -plt.plot(t, s) |
12 |
| -plt.grid(True) |
13 |
| - |
14 |
| -# MATLAB style |
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() |
31 |
| - |
32 |
| - |
33 |
| -""" |
34 |
| -# the same script, python style |
35 |
| -from pylab import * |
36 |
| -
|
37 |
| -t = arange(0.0, 2.0, 0.01) |
38 |
| -s = sin(2*pi*t) |
| 9 | +s = np.sin(2 * np.pi * t) |
39 | 10 | fig, ax = plt.subplots()
|
40 | 11 | ax.plot(t, s)
|
41 | 12 | ax.grid(True)
|
42 | 13 |
|
43 | 14 | ticklines = ax.get_xticklines()
|
44 |
| -ticklines.extend( ax.get_yticklines() ) |
| 15 | +ticklines.extend(ax.get_yticklines()) |
45 | 16 | gridlines = ax.get_xgridlines()
|
46 |
| -gridlines.extend( ax.get_ygridlines() ) |
| 17 | +gridlines.extend(ax.get_ygridlines()) |
47 | 18 | ticklabels = ax.get_xticklabels()
|
48 |
| -ticklabels.extend( ax.get_yticklabels() ) |
| 19 | +ticklabels.extend(ax.get_yticklabels()) |
49 | 20 |
|
50 | 21 | for line in ticklines:
|
51 | 22 | line.set_linewidth(3)
|
|
57 | 28 | label.set_color('r')
|
58 | 29 | label.set_fontsize('medium')
|
59 | 30 |
|
60 |
| -show() |
61 |
| -
|
62 |
| -""" |
| 31 | +plt.show() |
0 commit comments