Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitf5c1ab7

Browse files
committed
Add example for label_outer.
1 parent27d669c commitf5c1ab7

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

‎examples/pylab_examples/subplots_demo.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,32 @@
2222

2323
# Two subplots, the axes array is 1-d
2424
f,axarr=plt.subplots(2,sharex=True)
25+
f.suptitle('Sharing X axis')
2526
axarr[0].plot(x,y)
26-
axarr[0].set_title('Sharing X axis')
2727
axarr[1].scatter(x,y)
2828

2929
# Two subplots, unpack the axes array immediately
3030
f, (ax1,ax2)=plt.subplots(1,2,sharey=True)
31+
f.suptitle('Sharing Y axis')
3132
ax1.plot(x,y)
32-
ax1.set_title('Sharing Y axis')
3333
ax2.scatter(x,y)
3434

3535
# Three subplots sharing both x/y axes
36-
f, (ax1,ax2,ax3)=plt.subplots(3,sharex=True,sharey=True)
37-
ax1.plot(x,y)
38-
ax1.set_title('Sharing both axes')
39-
ax2.scatter(x,y)
40-
ax3.scatter(x,2*y**2-1,color='r')
41-
# Fine-tune figure; make subplots close to each other and hide x ticks for
42-
# all but bottom plot.
36+
f,axarr=plt.subplots(3,sharex=True,sharey=True)
37+
f.suptitle('Sharing both axes')
38+
axarr[0].plot(x,y)
39+
axarr[1].scatter(x,y)
40+
axarr[2].scatter(x,2*y**2-1,color='r')
41+
# Bring subplots close to each other.
4342
f.subplots_adjust(hspace=0)
44-
plt.setp([a.get_xticklabels()forainf.axes[:-1]],visible=False)
43+
# Hide x labels and tick labels for all but bottom plot.
44+
foraxinaxarr:
45+
ax.label_outer()
4546

4647
# row and column sharing
4748
f, ((ax1,ax2), (ax3,ax4))=plt.subplots(2,2,sharex='col',sharey='row')
49+
f.suptitle('Sharing x per column, y per row')
4850
ax1.plot(x,y)
49-
ax1.set_title('Sharing x per column, y per row')
5051
ax2.scatter(x,y)
5152
ax3.scatter(x,2*y**2-1,color='r')
5253
ax4.plot(x,2*y**2-1,color='r')
@@ -61,9 +62,11 @@
6162
axarr[1,0].set_title('Axis [1,0]')
6263
axarr[1,1].scatter(x,y**2)
6364
axarr[1,1].set_title('Axis [1,1]')
64-
# Fine-tune figure; hide x ticks for top plots and y ticks for right plots
65-
plt.setp([a.get_xticklabels()forainaxarr[0, :]],visible=False)
66-
plt.setp([a.get_yticklabels()forainaxarr[:,1]],visible=False)
65+
foraxinaxarr.flat:
66+
ax.set(xlabel='x-label',ylabel='y-label')
67+
# Hide x labels and tick labels for top plots and y ticks for right plots.
68+
foraxinaxarr.flat:
69+
ax.label_outer()
6770

6871
# Four polar axes
6972
f,axarr=plt.subplots(2,2,subplot_kw=dict(projection='polar'))

‎lib/matplotlib/axes/_subplots.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def is_last_row(self):
125125
defis_last_col(self):
126126
returnself.colNum==self.numCols-1
127127

128-
# COVERAGE NOTE: Never used internally or from examples
128+
# COVERAGE NOTE: Never used internally.
129129
deflabel_outer(self):
130130
"""Only show "outer" labels and tick labels.
131131

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp