@@ -25,11 +25,11 @@ def setup(ax):
2525 ax .patch .set_alpha (0.0 )
2626
2727
28- plt .figure (figsize = (8 , 6 ))
28+ fig = plt .figure (figsize = (8 , 6 ))
2929n = 7
3030
3131# Null formatter
32- ax = plt . subplot (n , 1 , 1 )
32+ ax = fig . add_subplot (n , 1 , 1 )
3333setup (ax )
3434ax .xaxis .set_major_locator (ticker .MultipleLocator (1.00 ))
3535ax .xaxis .set_minor_locator (ticker .MultipleLocator (0.25 ))
@@ -38,7 +38,7 @@ def setup(ax):
3838ax .text (0.0 , 0.1 , "NullFormatter()" , fontsize = 16 , transform = ax .transAxes )
3939
4040# Fixed formatter
41- ax = plt . subplot (n , 1 , 2 )
41+ ax = fig . add_subplot (n , 1 , 2 )
4242setup (ax )
4343ax .xaxis .set_major_locator (ticker .MultipleLocator (1.0 ))
4444ax .xaxis .set_minor_locator (ticker .MultipleLocator (0.25 ))
@@ -57,7 +57,7 @@ def major_formatter(x, pos):
5757 return "[%.2f]" % x
5858
5959
60- ax = plt . subplot (n , 1 , 3 )
60+ ax = fig . add_subplot (n , 1 , 3 )
6161setup (ax )
6262ax .xaxis .set_major_locator (ticker .MultipleLocator (1.00 ))
6363ax .xaxis .set_minor_locator (ticker .MultipleLocator (0.25 ))
@@ -67,7 +67,7 @@ def major_formatter(x, pos):
6767
6868
6969# FormatStr formatter
70- ax = plt . subplot (n , 1 , 4 )
70+ ax = fig . add_subplot (n , 1 , 4 )
7171setup (ax )
7272ax .xaxis .set_major_locator (ticker .MultipleLocator (1.00 ))
7373ax .xaxis .set_minor_locator (ticker .MultipleLocator (0.25 ))
@@ -76,15 +76,15 @@ def major_formatter(x, pos):
7676 fontsize = 15 , transform = ax .transAxes )
7777
7878# Scalar formatter
79- ax = plt . subplot (n , 1 , 5 )
79+ ax = fig . add_subplot (n , 1 , 5 )
8080setup (ax )
8181ax .xaxis .set_major_locator (ticker .AutoLocator ())
8282ax .xaxis .set_minor_locator (ticker .AutoMinorLocator ())
8383ax .xaxis .set_major_formatter (ticker .ScalarFormatter (useMathText = True ))
8484ax .text (0.0 , 0.1 , "ScalarFormatter()" , fontsize = 15 , transform = ax .transAxes )
8585
8686# StrMethod formatter
87- ax = plt . subplot (n , 1 , 6 )
87+ ax = fig . add_subplot (n , 1 , 6 )
8888setup (ax )
8989ax .xaxis .set_major_locator (ticker .MultipleLocator (1.00 ))
9090ax .xaxis .set_minor_locator (ticker .MultipleLocator (0.25 ))
@@ -93,7 +93,7 @@ def major_formatter(x, pos):
9393 fontsize = 15 , transform = ax .transAxes )
9494
9595# Percent formatter
96- ax = plt . subplot (n , 1 , 7 )
96+ ax = fig . add_subplot (n , 1 , 7 )
9797setup (ax )
9898ax .xaxis .set_major_locator (ticker .MultipleLocator (1.00 ))
9999ax .xaxis .set_minor_locator (ticker .MultipleLocator (0.25 ))
@@ -103,6 +103,6 @@ def major_formatter(x, pos):
103103
104104# Push the top of the top axes outside the figure because we only show the
105105# 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 )
107107
108108plt .show ()
0 commit comments