@@ -25,11 +25,11 @@ def setup(ax):
25
25
ax .patch .set_alpha (0.0 )
26
26
27
27
28
- plt .figure (figsize = (8 , 6 ))
28
+ fig = plt .figure (figsize = (8 , 6 ))
29
29
n = 7
30
30
31
31
# Null formatter
32
- ax = plt . subplot (n , 1 , 1 )
32
+ ax = fig . add_subplot (n , 1 , 1 )
33
33
setup (ax )
34
34
ax .xaxis .set_major_locator (ticker .MultipleLocator (1.00 ))
35
35
ax .xaxis .set_minor_locator (ticker .MultipleLocator (0.25 ))
@@ -38,7 +38,7 @@ def setup(ax):
38
38
ax .text (0.0 , 0.1 , "NullFormatter()" , fontsize = 16 , transform = ax .transAxes )
39
39
40
40
# Fixed formatter
41
- ax = plt . subplot (n , 1 , 2 )
41
+ ax = fig . add_subplot (n , 1 , 2 )
42
42
setup (ax )
43
43
ax .xaxis .set_major_locator (ticker .MultipleLocator (1.0 ))
44
44
ax .xaxis .set_minor_locator (ticker .MultipleLocator (0.25 ))
@@ -57,7 +57,7 @@ def major_formatter(x, pos):
57
57
return "[%.2f]" % x
58
58
59
59
60
- ax = plt . subplot (n , 1 , 3 )
60
+ ax = fig . add_subplot (n , 1 , 3 )
61
61
setup (ax )
62
62
ax .xaxis .set_major_locator (ticker .MultipleLocator (1.00 ))
63
63
ax .xaxis .set_minor_locator (ticker .MultipleLocator (0.25 ))
@@ -67,7 +67,7 @@ def major_formatter(x, pos):
67
67
68
68
69
69
# FormatStr formatter
70
- ax = plt . subplot (n , 1 , 4 )
70
+ ax = fig . add_subplot (n , 1 , 4 )
71
71
setup (ax )
72
72
ax .xaxis .set_major_locator (ticker .MultipleLocator (1.00 ))
73
73
ax .xaxis .set_minor_locator (ticker .MultipleLocator (0.25 ))
@@ -76,15 +76,15 @@ def major_formatter(x, pos):
76
76
fontsize = 15 , transform = ax .transAxes )
77
77
78
78
# Scalar formatter
79
- ax = plt . subplot (n , 1 , 5 )
79
+ ax = fig . add_subplot (n , 1 , 5 )
80
80
setup (ax )
81
81
ax .xaxis .set_major_locator (ticker .AutoLocator ())
82
82
ax .xaxis .set_minor_locator (ticker .AutoMinorLocator ())
83
83
ax .xaxis .set_major_formatter (ticker .ScalarFormatter (useMathText = True ))
84
84
ax .text (0.0 , 0.1 , "ScalarFormatter()" , fontsize = 15 , transform = ax .transAxes )
85
85
86
86
# StrMethod formatter
87
- ax = plt . subplot (n , 1 , 6 )
87
+ ax = fig . add_subplot (n , 1 , 6 )
88
88
setup (ax )
89
89
ax .xaxis .set_major_locator (ticker .MultipleLocator (1.00 ))
90
90
ax .xaxis .set_minor_locator (ticker .MultipleLocator (0.25 ))
@@ -93,7 +93,7 @@ def major_formatter(x, pos):
93
93
fontsize = 15 , transform = ax .transAxes )
94
94
95
95
# Percent formatter
96
- ax = plt . subplot (n , 1 , 7 )
96
+ ax = fig . add_subplot (n , 1 , 7 )
97
97
setup (ax )
98
98
ax .xaxis .set_major_locator (ticker .MultipleLocator (1.00 ))
99
99
ax .xaxis .set_minor_locator (ticker .MultipleLocator (0.25 ))
@@ -103,6 +103,6 @@ def major_formatter(x, pos):
103
103
104
104
# Push the top of the top axes outside the figure because we only show the
105
105
# bottom spine.
106
- plt .subplots_adjust (left = 0.05 , right = 0.95 , bottom = 0.05 , top = 1.05 )
106
+ fig .subplots_adjust (left = 0.05 , right = 0.95 , bottom = 0.05 , top = 1.05 )
107
107
108
108
plt .show ()
0 commit comments