@@ -92,25 +92,22 @@ def __call__(self, x):
9292 counts += counts .min ()
9393
9494fig = plt .figure ()
95- fig .subplots_adjust (hspace = 0.3 )
96-
97- ax1 = fig .add_subplot (211 )
98- ax2 = fig .add_subplot (212 , sharex = ax1 , sharey = ax1 )
95+ ax1 = fig .add_subplot (111 )
96+ ax2 = fig .add_subplot (111 , sharex = ax1 , sharey = ax1 , frameon = False )
9997
10098ax1 .plot (temp_C , counts , drawstyle = 'steps-mid' )
101- ax2 .plot (temp_C , counts , drawstyle = 'steps-mid' )
10299
103100ax1 .xaxis .set_major_formatter (StrMethodFormatter ('{x:0.2f}' ))
104101
105102# This step is necessary to allow the shared x-axes to have different
106103# Formatter and Locator objects.
107104ax2 .xaxis .major = Ticker ()
108105# 0C -> 491.67R (definition), -273.15C (0K)->0R (-491.67F)(definition)
106+ ax2 .xaxis .set_major_locator (ax1 .xaxis .get_major_locator ())
109107ax2 .xaxis .set_major_formatter (
110108 TransformFormatter (LinearTransform (in_start = - 273.15 , in_end = 0 ,
111109 out_end = 491.67 ),
112110 StrMethodFormatter ('{x:0.2f}' )))
113- ax2 .xaxis .set_major_locator (ax1 .xaxis .get_major_locator ())
114111
115112# The y-axes share their locators and formatters, so only one needs to
116113# be set
@@ -120,11 +117,12 @@ def __call__(self, x):
120117ax1 .yaxis .set_major_formatter (
121118 TransformFormatter (int , StrMethodFormatter ('{x:02X}' )))
122119
123- fig .suptitle ('Temperature vs Counts' )
124- ax1 .set_xlabel ('Temp (\u00B0 C)' )
120+ ax1 .set_xlabel ('Temperature (\u00B0 C)' )
125121ax1 .set_ylabel ('Samples (Hex)' )
126- ax2 .set_xlabel ('Temp (\u00B0 R)' )
127- ax2 .set_ylabel ('Samples (Hex)' )
122+ ax2 .set_xlabel ('Temperature (\u00B0 R)' )
123+
124+ ax1 .xaxis .tick_top ()
125+ ax1 .xaxis .set_label_position ('top' )
128126
129127plt .show ()
130128
0 commit comments