@@ -3289,6 +3289,136 @@ def test_hist_step_bottom():
3289
3289
ax .hist (d1 , bottom = np .arange (10 ), histtype = "stepfilled" )
3290
3290
3291
3291
3292
+ def test_hist_stepfilled_geometry ():
3293
+ bins = [0 , 1 , 2 , 3 ]
3294
+ data = [0 , 0 , 1 , 1 , 1 , 2 ]
3295
+ _ , _ , (polygon , ) = plt .hist (data ,
3296
+ bins = bins ,
3297
+ histtype = 'stepfilled' )
3298
+ xy = [[0 , 0 ], [0 , 2 ], [1 , 2 ], [1 , 3 ], [2 , 3 ], [2 , 1 ], [3 , 1 ],
3299
+ [3 , 0 ], [2 , 0 ], [2 , 0 ], [1 , 0 ], [1 , 0 ], [0 , 0 ]]
3300
+ assert_array_equal (polygon .get_xy (), xy )
3301
+
3302
+
3303
+ def test_hist_step_geometry ():
3304
+ bins = [0 , 1 , 2 , 3 ]
3305
+ data = [0 , 0 , 1 , 1 , 1 , 2 ]
3306
+ _ , _ , (polygon , ) = plt .hist (data ,
3307
+ bins = bins ,
3308
+ histtype = 'step' )
3309
+ xy = [[0 , 0 ], [0 , 2 ], [1 , 2 ], [1 , 3 ], [2 , 3 ], [2 , 1 ], [3 , 1 ], [3 , 0 ]]
3310
+ assert_array_equal (polygon .get_xy (), xy )
3311
+
3312
+
3313
+ def test_hist_stepfilled_bottom_geometry ():
3314
+ bins = [0 , 1 , 2 , 3 ]
3315
+ data = [0 , 0 , 1 , 1 , 1 , 2 ]
3316
+ _ , _ , (polygon , ) = plt .hist (data ,
3317
+ bins = bins ,
3318
+ bottom = [1 , 2 , 1.5 ],
3319
+ histtype = 'stepfilled' )
3320
+ xy = [[0 , 1 ], [0 , 3 ], [1 , 3 ], [1 , 5 ], [2 , 5 ], [2 , 2.5 ], [3 , 2.5 ],
3321
+ [3 , 1.5 ], [2 , 1.5 ], [2 , 2 ], [1 , 2 ], [1 , 1 ], [0 , 1 ]]
3322
+ assert_array_equal (polygon .get_xy (), xy )
3323
+
3324
+
3325
+ def test_hist_step_bottom_geometry ():
3326
+ bins = [0 , 1 , 2 , 3 ]
3327
+ data = [0 , 0 , 1 , 1 , 1 , 2 ]
3328
+ _ , _ , (polygon , ) = plt .hist (data ,
3329
+ bins = bins ,
3330
+ bottom = [1 , 2 , 1.5 ],
3331
+ histtype = 'step' )
3332
+ xy = [[0 , 1 ], [0 , 3 ], [1 , 3 ], [1 , 5 ], [2 , 5 ], [2 , 2.5 ], [3 , 2.5 ], [3 , 1.5 ]]
3333
+ assert_array_equal (polygon .get_xy (), xy )
3334
+
3335
+
3336
+ def test_hist_stacked_stepfilled_geometry ():
3337
+ bins = [0 , 1 , 2 , 3 ]
3338
+ data_1 = [0 , 0 , 1 , 1 , 1 , 2 ]
3339
+ data_2 = [0 , 1 , 2 ]
3340
+ _ , _ , patches = plt .hist ([data_1 , data_2 ],
3341
+ bins = bins ,
3342
+ stacked = True ,
3343
+ histtype = 'stepfilled' )
3344
+
3345
+ assert len (patches ) == 2
3346
+
3347
+ polygon , = patches [0 ]
3348
+ xy = [[0 , 0 ], [0 , 2 ], [1 , 2 ], [1 , 3 ], [2 , 3 ], [2 , 1 ], [3 , 1 ],
3349
+ [3 , 0 ], [2 , 0 ], [2 , 0 ], [1 , 0 ], [1 , 0 ], [0 , 0 ]]
3350
+ assert_array_equal (polygon .get_xy (), xy )
3351
+
3352
+ polygon , = patches [1 ]
3353
+ xy = [[0 , 2 ], [0 , 3 ], [1 , 3 ], [1 , 4 ], [2 , 4 ], [2 , 2 ], [3 , 2 ],
3354
+ [3 , 1 ], [2 , 1 ], [2 , 3 ], [1 , 3 ], [1 , 2 ], [0 , 2 ]]
3355
+ assert_array_equal (polygon .get_xy (), xy )
3356
+
3357
+
3358
+ def test_hist_stacked_step_geometry ():
3359
+ bins = [0 , 1 , 2 , 3 ]
3360
+ data_1 = [0 , 0 , 1 , 1 , 1 , 2 ]
3361
+ data_2 = [0 , 1 , 2 ]
3362
+ _ , _ , patches = plt .hist ([data_1 , data_2 ],
3363
+ bins = bins ,
3364
+ stacked = True ,
3365
+ histtype = 'step' )
3366
+
3367
+ assert len (patches ) == 2
3368
+
3369
+ polygon , = patches [0 ]
3370
+ xy = [[0 , 0 ], [0 , 2 ], [1 , 2 ], [1 , 3 ], [2 , 3 ], [2 , 1 ], [3 , 1 ], [3 , 0 ]]
3371
+ assert_array_equal (polygon .get_xy (), xy )
3372
+
3373
+ polygon , = patches [1 ]
3374
+ xy = [[0 , 2 ], [0 , 3 ], [1 , 3 ], [1 , 4 ], [2 , 4 ], [2 , 2 ], [3 , 2 ], [3 , 1 ]]
3375
+ assert_array_equal (polygon .get_xy (), xy )
3376
+
3377
+
3378
+ def test_hist_stacked_stepfilled_bottom_geometry ():
3379
+ bins = [0 , 1 , 2 , 3 ]
3380
+ data_1 = [0 , 0 , 1 , 1 , 1 , 2 ]
3381
+ data_2 = [0 , 1 , 2 ]
3382
+ _ , _ , patches = plt .hist ([data_1 , data_2 ],
3383
+ bins = bins ,
3384
+ stacked = True ,
3385
+ bottom = [1 , 2 , 1.5 ],
3386
+ histtype = 'stepfilled' )
3387
+
3388
+ assert len (patches ) == 2
3389
+
3390
+ polygon , = patches [0 ]
3391
+ xy = [[0 , 1 ], [0 , 3 ], [1 , 3 ], [1 , 5 ], [2 , 5 ], [2 , 2.5 ], [3 , 2.5 ],
3392
+ [3 , 1.5 ], [2 , 1.5 ], [2 , 2 ], [1 , 2 ], [1 , 1 ], [0 , 1 ]]
3393
+ assert_array_equal (polygon .get_xy (), xy )
3394
+
3395
+ polygon , = patches [1 ]
3396
+ xy = [[0 , 3 ], [0 , 4 ], [1 , 4 ], [1 , 6 ], [2 , 6 ], [2 , 3.5 ], [3 , 3.5 ],
3397
+ [3 , 2.5 ], [2 , 2.5 ], [2 , 5 ], [1 , 5 ], [1 , 3 ], [0 , 3 ]]
3398
+ assert_array_equal (polygon .get_xy (), xy )
3399
+
3400
+
3401
+ def test_hist_stacked_step_bottom_geometry ():
3402
+ bins = [0 , 1 , 2 , 3 ]
3403
+ data_1 = [0 , 0 , 1 , 1 , 1 , 2 ]
3404
+ data_2 = [0 , 1 , 2 ]
3405
+ _ , _ , patches = plt .hist ([data_1 , data_2 ],
3406
+ bins = bins ,
3407
+ stacked = True ,
3408
+ bottom = [1 , 2 , 1.5 ],
3409
+ histtype = 'step' )
3410
+
3411
+ assert len (patches ) == 2
3412
+
3413
+ polygon , = patches [0 ]
3414
+ xy = [[0 , 1 ], [0 , 3 ], [1 , 3 ], [1 , 5 ], [2 , 5 ], [2 , 2.5 ], [3 , 2.5 ], [3 , 1.5 ]]
3415
+ assert_array_equal (polygon .get_xy (), xy )
3416
+
3417
+ polygon , = patches [1 ]
3418
+ xy = [[0 , 3 ], [0 , 4 ], [1 , 4 ], [1 , 6 ], [2 , 6 ], [2 , 3.5 ], [3 , 3.5 ], [3 , 2.5 ]]
3419
+ assert_array_equal (polygon .get_xy (), xy )
3420
+
3421
+
3292
3422
@image_comparison (['hist_stacked_bar' ])
3293
3423
def test_hist_stacked_bar ():
3294
3424
# make some data
0 commit comments