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

Skip to content

Commit f4773e0

Browse files
committed
spines: new example
svn path=/trunk/matplotlib/; revision=8042
1 parent 9a44572 commit f4773e0

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

examples/pylab_examples/spine_placement_demo.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,34 @@ def adjust_spines(ax,spines):
113113
ax.plot(x,y)
114114
adjust_spines(ax,['bottom'])
115115

116+
# ----------------------------------------------------
117+
118+
fig = plt.figure()
119+
120+
x = np.linspace(0,2*np.pi,50)
121+
y = np.sin(x)
122+
y2 = y + 0.1*np.random.normal( size=x.shape )
123+
124+
# plot data
125+
ax = fig.add_subplot(1,1,1)
126+
line1,=ax.plot(x,y,'--')
127+
line2,=ax.plot(x,y2,'bo')
128+
129+
# adjust the spines
130+
adjust_spines(ax,['left','bottom'])
131+
132+
# set ticks and tick labels
133+
# x
134+
ax.set_xlim((0,2*np.pi))
135+
ax.set_xticks([0,np.pi,2*np.pi])
136+
pichr = unichr(0x03C0)
137+
ax.set_xticklabels(['0',pichr,'2 '+pichr])
138+
139+
# y
140+
ax.set_yticks([-1,0,1])
141+
142+
# disable clipping of data points by axes range
143+
for artist in (line1,line2):
144+
artist.set_clip_on(False)
145+
116146
show()

0 commit comments

Comments
 (0)