@@ -26,18 +26,18 @@ def demo_simple_image(ax):
2626 plt .setp (cb .ax .get_yticklabels (), visible = False )
2727
2828
29- def demo_locatable_axes_hard (fig1 ):
29+ def demo_locatable_axes_hard (fig ):
3030
3131 from mpl_toolkits .axes_grid1 import SubplotDivider , Size
3232 from mpl_toolkits .axes_grid1 .mpl_axes import Axes
3333
34- divider = SubplotDivider (fig1 , 2 , 2 , 2 , aspect = True )
34+ divider = SubplotDivider (fig , 2 , 2 , 2 , aspect = True )
3535
3636 # axes for image
37- ax = Axes (fig1 , divider .get_position ())
37+ ax = Axes (fig , divider .get_position ())
3838
3939 # axes for colorbar
40- ax_cb = Axes (fig1 , divider .get_position ())
40+ ax_cb = Axes (fig , divider .get_position ())
4141
4242 h = [Size .AxesX (ax ), # main axes
4343 Size .Fixed (0.05 ), # padding, 0.1 inch
@@ -52,8 +52,8 @@ def demo_locatable_axes_hard(fig1):
5252 ax .set_axes_locator (divider .new_locator (nx = 0 , ny = 0 ))
5353 ax_cb .set_axes_locator (divider .new_locator (nx = 2 , ny = 0 ))
5454
55- fig1 .add_axes (ax )
56- fig1 .add_axes (ax_cb )
55+ fig .add_axes (ax )
56+ fig .add_axes (ax_cb )
5757
5858 ax_cb .axis ["left" ].toggle (all = False )
5959 ax_cb .axis ["right" ].toggle (ticks = True )
@@ -71,8 +71,8 @@ def demo_locatable_axes_easy(ax):
7171 divider = make_axes_locatable (ax )
7272
7373 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 )
7676
7777 Z , extent = get_demo_image ()
7878 im = ax .imshow (Z , extent = extent , interpolation = "nearest" )
@@ -99,31 +99,30 @@ def demo_images_side_by_side(ax):
9999
100100def demo ():
101101
102- fig1 = plt .figure (1 , (6 , 6 ))
103- fig1 .clf ()
102+ fig = plt .figure (figsize = (6 , 6 ))
104103
105104 # PLOT 1
106105 # simple image & colorbar
107- ax = fig1 .add_subplot (2 , 2 , 1 )
106+ ax = fig .add_subplot (2 , 2 , 1 )
108107 demo_simple_image (ax )
109108
110109 # PLOT 2
111110 # image and colorbar whose location is adjusted in the drawing time.
112111 # a hard way
113112
114- demo_locatable_axes_hard (fig1 )
113+ demo_locatable_axes_hard (fig )
115114
116115 # PLOT 3
117116 # image and colorbar whose location is adjusted in the drawing time.
118117 # a easy way
119118
120- ax = fig1 .add_subplot (2 , 2 , 3 )
119+ ax = fig .add_subplot (2 , 2 , 3 )
121120 demo_locatable_axes_easy (ax )
122121
123122 # PLOT 4
124123 # two images side by side with fixed padding.
125124
126- ax = fig1 .add_subplot (2 , 2 , 4 )
125+ ax = fig .add_subplot (2 , 2 , 4 )
127126 demo_images_side_by_side (ax )
128127
129128 plt .show ()
0 commit comments