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

Function test_set_offset_units

lib/matplotlib/tests/test_collections.py:1312–1329  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1310
1311
1312def test_set_offset_units():
1313 # passing the offsets in initially (i.e. via scatter)
1314 # should yield the same results as `set_offsets`
1315 x = np.linspace(0, 10, 5)
1316 y = np.sin(x)
1317 d = x * np.timedelta64(24, 'h') + np.datetime64('2021-11-29')
1318
1319 sc = plt.scatter(d, y)
1320 off0 = sc.get_offsets()
1321 sc.set_offsets(list(zip(d, y)))
1322 np.testing.assert_allclose(off0, sc.get_offsets())
1323
1324 # try the other way around
1325 fig, ax = plt.subplots()
1326 sc = ax.scatter(y, d)
1327 off0 = sc.get_offsets()
1328 sc.set_offsets(list(zip(y, d)))
1329 np.testing.assert_allclose(off0, sc.get_offsets())
1330
1331
1332@image_comparison(["test_check_masked_offsets.png"], remove_text=True, style="mpl20")

Callers

nothing calls this directly

Calls 4

get_offsetsMethod · 0.80
scatterMethod · 0.45
set_offsetsMethod · 0.45
subplotsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…