@@ -26,18 +26,18 @@ def demo_simple_image(ax):
26
26
plt .setp (cb .ax .get_yticklabels (), visible = False )
27
27
28
28
29
- def demo_locatable_axes_hard (fig1 ):
29
+ def demo_locatable_axes_hard (fig ):
30
30
31
31
from mpl_toolkits .axes_grid1 import SubplotDivider , Size
32
32
from mpl_toolkits .axes_grid1 .mpl_axes import Axes
33
33
34
- divider = SubplotDivider (fig1 , 2 , 2 , 2 , aspect = True )
34
+ divider = SubplotDivider (fig , 2 , 2 , 2 , aspect = True )
35
35
36
36
# axes for image
37
- ax = Axes (fig1 , divider .get_position ())
37
+ ax = Axes (fig , divider .get_position ())
38
38
39
39
# axes for colorbar
40
- ax_cb = Axes (fig1 , divider .get_position ())
40
+ ax_cb = Axes (fig , divider .get_position ())
41
41
42
42
h = [Size .AxesX (ax ), # main axes
43
43
Size .Fixed (0.05 ), # padding, 0.1 inch
@@ -52,8 +52,8 @@ def demo_locatable_axes_hard(fig1):
52
52
ax .set_axes_locator (divider .new_locator (nx = 0 , ny = 0 ))
53
53
ax_cb .set_axes_locator (divider .new_locator (nx = 2 , ny = 0 ))
54
54
55
- fig1 .add_axes (ax )
56
- fig1 .add_axes (ax_cb )
55
+ fig .add_axes (ax )
56
+ fig .add_axes (ax_cb )
57
57
58
58
ax_cb .axis ["left" ].toggle (all = False )
59
59
ax_cb .axis ["right" ].toggle (ticks = True )
@@ -71,8 +71,8 @@ def demo_locatable_axes_easy(ax):
71
71
divider = make_axes_locatable (ax )
72
72
73
73
ax_cb = divider .new_horizontal (size = "5%" , pad = 0.05 )
74
- fig1 = ax .get_figure ()
75
- fig1 .add_axes (ax_cb )
74
+ fig = ax .get_figure ()
75
+ fig .add_axes (ax_cb )
76
76
77
77
Z , extent = get_demo_image ()
78
78
im = ax .imshow (Z , extent = extent , interpolation = "nearest" )
@@ -99,31 +99,30 @@ def demo_images_side_by_side(ax):
99
99
100
100
def demo ():
101
101
102
- fig1 = plt .figure (1 , (6 , 6 ))
103
- fig1 .clf ()
102
+ fig = plt .figure (figsize = (6 , 6 ))
104
103
105
104
# PLOT 1
106
105
# simple image & colorbar
107
- ax = fig1 .add_subplot (2 , 2 , 1 )
106
+ ax = fig .add_subplot (2 , 2 , 1 )
108
107
demo_simple_image (ax )
109
108
110
109
# PLOT 2
111
110
# image and colorbar whose location is adjusted in the drawing time.
112
111
# a hard way
113
112
114
- demo_locatable_axes_hard (fig1 )
113
+ demo_locatable_axes_hard (fig )
115
114
116
115
# PLOT 3
117
116
# image and colorbar whose location is adjusted in the drawing time.
118
117
# a easy way
119
118
120
- ax = fig1 .add_subplot (2 , 2 , 3 )
119
+ ax = fig .add_subplot (2 , 2 , 3 )
121
120
demo_locatable_axes_easy (ax )
122
121
123
122
# PLOT 4
124
123
# two images side by side with fixed padding.
125
124
126
- ax = fig1 .add_subplot (2 , 2 , 4 )
125
+ ax = fig .add_subplot (2 , 2 , 4 )
127
126
demo_images_side_by_side (ax )
128
127
129
128
plt .show ()
0 commit comments