File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
examples/subplots_axes_and_figures Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change
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 .
42BA
start , rowspan2 .stop )
24
+
25
+ fig .align_titles ()
26
+ plt .show ()
You can’t perform that action at this time.
0 commit comments