1
1
"""
2
- ======================
3
- Demo Axes Hbox Divider
4
- ======================
2
+ ===================
3
+ `.HBoxDivider` demo
4
+ ===================
5
5
6
- Hbox Divider to arrange subplots.
6
+ Using an `.HBoxDivider` to arrange subplots.
7
7
"""
8
8
9
9
import numpy as np
@@ -31,22 +31,13 @@ def make_heights_equal(fig, rect, ax1, ax2, pad):
31
31
ax1 .imshow (arr1 )
32
32
ax2 .imshow (arr2 )
33
33
34
- pad = 0.5 # inches.
35
- divider = HBoxDivider (
36
- fig , 111 , # Position of combined axes.
37
- horizontal = [Size .AxesX (ax1 ), Size .Fixed (pad ), Size .AxesX (ax2 )],
38
- vertical = [Size .AxesY (ax1 ), Size .Scaled (1 ), Size .AxesY (ax2 )])
39
- ax1 .set_axes_locator (divider .new_locator (0 ))
40
- ax2 .set_axes_locator (divider .new_locator (2 ))
34
+ make_heights_equal (fig , 111 , ax1 , ax2 , pad = 0.5 )
41
35
42
- # annotate
43
- ax3 = plt .axes ([0.5 , 0.5 , 0.001 , 0.001 ], frameon = False )
44
- ax3 .xaxis .set_visible (False )
45
- ax3 .yaxis .set_visible (False )
46
- ax3 .annotate ("Location of two axes are adjusted\n "
47
- "so that they have equal heights\n "
48
- "while maintaining their aspect ratios" , (0.5 , 0.5 ),
49
- xycoords = "axes fraction" , va = "center" , ha = "center" ,
50
- bbox = dict (boxstyle = "round, pad=1" , fc = "w" ))
36
+ fig .text (.5 , .5 ,
37
+ "Both axes' location are adjusted\n "
38
+ "so that they have equal heights\n "
39
+ "while maintaining their aspect ratios" ,
40
+ va = "center" , ha = "center" ,
41
+ bbox = dict (boxstyle = "round, pad=1" , facecolor = "w" ))
51
42
52
43
plt .show ()
0 commit comments