MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_relim_collection

Function test_relim_collection

lib/matplotlib/tests/test_axes.py:6540–6562  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6538
6539
6540def 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
6565def test_relim_collection_autolim_false():

Callers

nothing calls this directly

Calls 8

relimMethod · 0.80
subplotsMethod · 0.45
scatterMethod · 0.45
get_datalimMethod · 0.45
get_pointsMethod · 0.45
set_offsetsMethod · 0.45
plotMethod · 0.45
set_visibleMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…