Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 438bc94

Browse filesBrowse files
committed
Merge pull request #4831 from ericmjl/mep12_axes_props.py
mep12 changes to axes_props.py
2 parents a67c880 + 3907ecd commit 438bc94
Copy full SHA for 438bc94

File tree

Expand file treeCollapse file tree

1 file changed

+5
-39
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-39
lines changed

‎examples/pylab_examples/axes_props.py

Copy file name to clipboard
+5-39Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env python
21
"""
32
You can control the axis tick and grid properties
43
"""
@@ -7,45 +6,14 @@
76
import numpy as np
87

98
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)
3910
fig, ax = plt.subplots()
4011
ax.plot(t, s)
4112
ax.grid(True)
4213

43-
ticklines = ax.get_xticklines()
44-
ticklines.extend( ax.get_yticklines() )
45-
gridlines = ax.get_xgridlines()
46-
gridlines.extend( ax.get_ygridlines() )
47-
ticklabels = ax.get_xticklabels()
48-
ticklabels.extend( ax.get_yticklabels() )
14+
ticklines = ax.get_xticklines() + ax.get_yticklines()
15+
gridlines = ax.get_xgridlines() + ax.get_ygridlines()
16+
ticklabels = ax.get_xticklabels() + ax.get_yticklabels()
4917

5018
for line in ticklines:
5119
line.set_linewidth(3)
@@ -57,6 +25,4 @@
5725
label.set_color('r')
5826
label.set_fontsize('medium')
5927

60-
show()
61-
62-
"""
28+
plt.show()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.