| 5157 | |
| 5158 | |
| 5159 | def test_hist_stacked_step_geometry(): |
| 5160 | bins = [0, 1, 2, 3] |
| 5161 | data_1 = [0, 0, 1, 1, 1, 2] |
| 5162 | data_2 = [0, 1, 2] |
| 5163 | tops = [ |
| 5164 | [[0, 0], [0, 2], [1, 2], [1, 3], [2, 3], [2, 1], [3, 1], [3, 0]], |
| 5165 | [[0, 2], [0, 3], [1, 3], [1, 4], [2, 4], [2, 2], [3, 2], [3, 1]], |
| 5166 | ] |
| 5167 | bottoms = [ |
| 5168 | [[2, 0], [2, 0], [1, 0], [1, 0], [0, 0]], |
| 5169 | [[2, 1], [2, 3], [1, 3], [1, 2], [0, 2]], |
| 5170 | ] |
| 5171 | combined = [t + b for t, b in zip(tops, bottoms)] |
| 5172 | |
| 5173 | for histtype, xy in [('step', tops), ('stepfilled', combined)]: |
| 5174 | _, _, patches = plt.hist([data_1, data_2], bins=bins, stacked=True, |
| 5175 | histtype=histtype) |
| 5176 | assert len(patches) == 2 |
| 5177 | polygon, = patches[0] |
| 5178 | assert_array_equal(polygon.get_xy(), xy[0]) |
| 5179 | polygon, = patches[1] |
| 5180 | assert_array_equal(polygon.get_xy(), xy[1]) |
| 5181 | |
| 5182 | |
| 5183 | def test_hist_stacked_step_bottom_geometry(): |