Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1b72df1

Browse files
author
domspad
committed
pylab to plt and np
1 parent b6b0514 commit 1b72df1

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

examples/pylab_examples/axes_props.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,31 @@
33
You can control the axis tick and grid properties
44
"""
55

6-
from pylab import *
6+
import matplotlib.pyplot as plt
7+
import numpy as np
78

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)
1213

1314
# 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()
3031

3132

3233
"""

0 commit comments

Comments
 (0)