@@ -128,12 +128,12 @@ def test_jpl_bar_units():
128
128
units .register ()
129
129
130
130
day = units .Duration ("ET" , 24.0 * 60.0 * 60.0 )
131
- x = [0 * units .km , 1 * units .km , 2 * units .km ]
132
- w = [1 * day , 2 * day , 3 * day ]
131
+ x = [0 * units .km , 1 * units .km , 2 * units .km ]
132
+ w = [1 * day , 2 * day , 3 * day ]
133
133
b = units .Epoch ("ET" , dt = datetime (2009 , 4 , 25 ))
134
134
fig , ax = plt .subplots ()
135
135
ax .bar (x , w , bottom = b )
136
- ax .set_ylim ([b - 1 * day , b + w [- 1 ]+ (1.001 )* day ])
136
+ ax .set_ylim ([b - 1 * day , b + w [- 1 ] + (1.001 ) * day ])
137
137
138
138
139
139
@image_comparison (['jpl_barh_units.png' ],
@@ -143,13 +143,13 @@ def test_jpl_barh_units():
143
143
units .register ()
144
144
145
145
day = units .Duration ("ET" , 24.0 * 60.0 * 60.0 )
146
- x = [0 * units .km , 1 * units .km , 2 * units .km ]
147
- w = [1 * day , 2 * day , 3 * day ]
146
+ x = [0 * units .km , 1 * units .km , 2 * units .km ]
147
+ w = [1 * day , 2 * day , 3 * day ]
148
148
b = units .Epoch ("ET" , dt = datetime (2009 , 4 , 25 ))
149
149
150
150
fig , ax = plt .subplots ()
151
151
ax .barh (x , w , left = b )
152
- ax .set_xlim ([b - 1 * day , b + w [- 1 ]+ (1.001 )* day ])
152
+ ax .set_xlim ([b - 1 * day , b + w [- 1 ] + (1.001 ) * day ])
153
153
154
154
155
155
def test_empty_arrays ():
@@ -175,7 +175,7 @@ class subdate(datetime):
175
175
fig_ref .subplots ().plot (datetime (2000 , 1 , 1 ), 0 , "o" )
176
176
177
177
178
- def test_set_xyunits (quantity_converter ):
178
+ def test_shared_axis_quantity (quantity_converter ):
179
179
munits .registry [Quantity ] = quantity_converter
180
180
x = Quantity (np .linspace (0 , 1 , 10 ), "hours" )
181
181
y1 = Quantity (np .linspace (1 , 2 , 10 ), "feet" )
@@ -189,13 +189,21 @@ def test_set_xyunits(quantity_converter):
189
189
ax2 .yaxis .set_units ("inches" )
190
190
assert ax1 .xaxis .get_units () == ax2 .xaxis .get_units () == "seconds"
191
191
assert ax1 .yaxis .get_units () == ax2 .yaxis .get_units () == "inches"
192
+
193
+
194
+ def test_shared_axis_datetime ():
195
+ # datetime uses dates.DateConverter
192
196
y1 = [datetime (2020 , i , 1 , tzinfo = timezone .utc ) for i in range (1 , 13 )]
193
197
y2 = [datetime (2021 , i , 1 , tzinfo = timezone .utc ) for i in range (1 , 13 )]
194
198
fig , (ax1 , ax2 ) = plt .subplots (1 , 2 , sharey = True )
195
199
ax1 .plot (y1 )
196
200
ax2 .plot (y2 )
197
201
ax1 .yaxis .set_units (timezone (timedelta (hours = 5 )))
198
202
assert ax2 .yaxis .units == timezone (timedelta (hours = 5 ))
203
+
204
+
205
+ def test_shared_axis_categorical ():
206
+ # str uses category.StrCategoryConverter
199
207
d1 = {"a" : 1 , "b" : 2 }
200
208
d2 = {"a" : 3 , "b" : 4 }
201
209
fig , (ax1 , ax2 ) = plt .subplots (1 , 2 , sharex = True , sharey = True )
0 commit comments