()
| 6538 | |
| 6539 | |
| 6540 | def test_relim_collection(): |
| 6541 | fig, ax = plt.subplots() |
| 6542 | sc = ax.scatter([1, 2, 3], [4, 5, 6]) |
| 6543 | ax.relim() |
| 6544 | expected = sc.get_datalim(ax.transData) |
| 6545 | assert_allclose(ax.dataLim.get_points(), expected.get_points()) |
| 6546 | assert_allclose(ax.dataLim.minpos, expected.minpos) |
| 6547 | |
| 6548 | # After updating offsets, relim should track the new data. |
| 6549 | sc.set_offsets([[10, 20], [30, 40]]) |
| 6550 | ax.relim() |
| 6551 | expected = sc.get_datalim(ax.transData) |
| 6552 | assert_allclose(ax.dataLim.get_points(), expected.get_points()) |
| 6553 | assert_allclose(ax.dataLim.minpos, expected.minpos) |
| 6554 | |
| 6555 | # visible_only=True should ignore hidden collections. |
| 6556 | line, = ax.plot([0, 1], [0, 1]) |
| 6557 | sc.set_visible(False) |
| 6558 | ax.relim(visible_only=True) |
| 6559 | # With scatter hidden, limits should be driven by the line only. |
| 6560 | assert_allclose(ax.dataLim.get_points(), [[0, 0], [1, 1]]) |
| 6561 | # minpos is the minimum *positive* value; line data [0, 1] gives 1.0. |
| 6562 | assert_array_equal(ax.dataLim.minpos, [1., 1.]) |
| 6563 | |
| 6564 | |
| 6565 | def test_relim_collection_autolim_false(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…