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

Skip to content

Commit a3d8ccd

Browse files
committed
add demo
1 parent 8b27ae3 commit a3d8ccd

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""
2+
===============
3+
Aligning Labels
4+
===============
5+
6+
Aligning titles using `.Figure.align_titles`.
7+
8+
Note that the title "Title 1" would normally be much closer to the
9+
figure's axis.
10+
"""
11+
import matplotlib.pyplot as plt
12+
fig, axs = plt.subplots(2, 2,
13+
subplot_kw={"xlabel": "x", "ylabel": "", "title": "t"})
14+
print(axs.shape)
15+
axs[0][0].imshow(plt.np.zeros((3, 5)))
16+
axs[0][1].imshow(plt.np.zeros((5, 3)))
17+
axs[1][0].imshow(plt.np.zeros((1, 2)))
18+
axs[1][1].imshow(plt.np.zeros((2, 1)))
19+
axs[0][0].set_title('t2')
20+
rowspan1 = axs[0][0].get_subplotspec().rowspan
21+
print(rowspan1, rowspan1.start, rowspan1.stop)
22+
rowspan2 = axs[1][1].get_subplotspec().rowspan
23+
print(rowspan2, rowspan2.start, rowspan2.stop)
24+
25+
fig.align_titles()
26+
plt.show()

0 commit comments

Comments
 (0)