@@ -305,22 +305,24 @@ def test_mappable_units(quantity_converter):
305
305
munits .registry [Quantity ] = quantity_converter
306
306
x , y = np .meshgrid ([0 , 1 ], [0 , 1 ])
307
307
data = Quantity (np .arange (4 ).reshape (2 , 2 ), 'hours' )
308
+ vmin = Quantity (1 , "hours" ) # Test a limit different from min of the data
309
+ vmax = Quantity (3 * 60 , "minutes" ) # Test a different unit to the data
308
310
309
- fig , axs = plt .subplots (nrows = 2 , ncols = 2 )
311
+ fig , axs = plt .subplots (nrows = 2 , ncols = 2 , constrained_layout = True )
310
312
311
313
# imshow
312
314
ax = axs [0 , 0 ]
313
- mappable = ax .imshow (data , origin = 'lower' )
314
- cbar = fig .colorbar (mappable , ax = ax )
315
+ mappable = ax .imshow (data , origin = 'lower' , vmin = vmin , vmax = vmax )
316
+ cbar = fig .colorbar (mappable , ax = ax , extend = "min" )
315
317
316
318
# pcolor
317
319
ax = axs [0 , 1 ]
318
- mappable = ax .pcolor (x , y , data )
319
- fig .colorbar (mappable , ax = ax )
320
+ mappable = ax .pcolor (x , y , data , vmin = vmin , vmax = vmax )
321
+ fig .colorbar (mappable , ax = ax , extend = "min" )
320
322
321
323
# pcolormesh + horizontal colorbar
322
324
ax = axs [1 , 0 ]
323
- mappable = ax .pcolormesh (x , y , data )
324
- fig .colorbar (mappable , ax = ax , orientation = "horizontal" )
325
+ mappable = ax .pcolormesh (x , y , data , vmin = vmin , vmax = vmax )
326
+ fig .colorbar (mappable , ax = ax , orientation = "horizontal" , extend = "min" )
325
327
326
328
axs [1 , 1 ].axis ("off" )
0 commit comments