22=====================
33Simple Axes Divider 1
44=====================
5+
6+ See also :doc:`/tutorials/toolkits/axes_grid`.
57"""
68
79from mpl_toolkits .axes_grid1 import Size , Divider
@@ -16,51 +18,48 @@ def label_axes(ax, text):
1618 left = False , labelleft = False )
1719
1820
19- ##############################################################################
20- # Fixed axes sizes; fixed paddings.
21+ fig = plt . figure ( figsize = ( 12 , 6 ))
22+ sfs = fig . subfigures ( 1 , 2 )
2123
22- fig = plt .figure (figsize = (6 , 6 ))
23- fig .suptitle ("Fixed axes sizes, fixed paddings" )
2424
25+ sfs [0 ].suptitle ("Fixed axes sizes, fixed paddings" )
2526# Sizes are in inches.
2627horiz = [Size .Fixed (1. ), Size .Fixed (.5 ), Size .Fixed (1.5 ), Size .Fixed (.5 )]
2728vert = [Size .Fixed (1.5 ), Size .Fixed (.5 ), Size .Fixed (1. )]
2829
2930rect = (0.1 , 0.1 , 0.8 , 0.8 )
3031# Divide the axes rectangle into a grid with sizes specified by horiz * vert.
31- divider = Divider (fig , rect , horiz , vert , aspect = False )
32+ div = Divider (sfs [ 0 ] , rect , horiz , vert , aspect = False )
3233
3334# The rect parameter will actually be ignored and overridden by axes_locator.
34- ax1 = fig .add_axes (rect , axes_locator = divider .new_locator (nx = 0 , ny = 0 ))
35+ ax1 = sfs [ 0 ] .add_axes (rect , axes_locator = div .new_locator (nx = 0 , ny = 0 ))
3536label_axes (ax1 , "nx=0, ny=0" )
36- ax2 = fig .add_axes (rect , axes_locator = divider .new_locator (nx = 0 , ny = 2 ))
37+ ax2 = sfs [ 0 ] .add_axes (rect , axes_locator = div .new_locator (nx = 0 , ny = 2 ))
3738label_axes (ax2 , "nx=0, ny=2" )
38- ax3 = fig .add_axes (rect , axes_locator = divider .new_locator (nx = 2 , ny = 2 ))
39+ ax3 = sfs [ 0 ] .add_axes (rect , axes_locator = div .new_locator (nx = 2 , ny = 2 ))
3940label_axes (ax3 , "nx=2, ny=2" )
40- ax4 = fig .add_axes (rect , axes_locator = divider .new_locator (nx = 2 , nx1 = 4 , ny = 0 ))
41+ ax4 = sfs [ 0 ] .add_axes (rect , axes_locator = div .new_locator (nx = 2 , nx1 = 4 , ny = 0 ))
4142label_axes (ax4 , "nx=2, nx1=4, ny=0" )
4243
43- ##############################################################################
44- # Axes sizes that scale with the figure size; fixed paddings.
45-
46- fig = plt .figure (figsize = (6 , 6 ))
47- fig .suptitle ("Scalable axes sizes, fixed paddings" )
4844
45+ sfs [1 ].suptitle ("Scalable axes sizes, fixed paddings" )
46+ # Fixed sizes are in inches, scaled sizes are relative.
4947horiz = [Size .Scaled (1.5 ), Size .Fixed (.5 ), Size .Scaled (1. ), Size .Scaled (.5 )]
5048vert = [Size .Scaled (1. ), Size .Fixed (.5 ), Size .Scaled (1.5 )]
5149
5250rect = (0.1 , 0.1 , 0.8 , 0.8 )
5351# Divide the axes rectangle into a grid with sizes specified by horiz * vert.
54- divider = Divider (fig , rect , horiz , vert , aspect = False )
52+ div = Divider (sfs [ 1 ] , rect , horiz , vert , aspect = False )
5553
5654# The rect parameter will actually be ignored and overridden by axes_locator.
57- ax1 = fig .add_axes (rect , axes_locator = divider .new_locator (nx = 0 , ny = 0 ))
55+ ax1 = sfs [ 1 ] .add_axes (rect , axes_locator = div .new_locator (nx = 0 , ny = 0 ))
5856label_axes (ax1 , "nx=0, ny=0" )
59- ax2 = fig .add_axes (rect , axes_locator = divider .new_locator (nx = 0 , ny = 2 ))
57+ ax2 = sfs [ 1 ] .add_axes (rect , axes_locator = div .new_locator (nx = 0 , ny = 2 ))
6058label_axes (ax2 , "nx=0, ny=2" )
61- ax3 = fig .add_axes (rect , axes_locator = divider .new_locator (nx = 2 , ny = 2 ))
59+ ax3 = sfs [ 1 ] .add_axes (rect , axes_locator = div .new_locator (nx = 2 , ny = 2 ))
6260label_axes (ax3 , "nx=2, ny=2" )
63- ax4 = fig .add_axes (rect , axes_locator = divider .new_locator (nx = 2 , nx1 = 4 , ny = 0 ))
61+ ax4 = sfs [ 1 ] .add_axes (rect , axes_locator = div .new_locator (nx = 2 , nx1 = 4 , ny = 0 ))
6462label_axes (ax4 , "nx=2, nx1=4, ny=0" )
6563
64+
6665plt .show ()
0 commit comments