Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def _prepare_points(self):
paths.append(mpath.Path(np.column_stack([xs, ys]), path.codes))
xs = self.convert_xunits(offsets[:, 0])
ys = self.convert_yunits(offsets[:, 1])
offsets = np.column_stack([xs, ys])
offsets = np.ma.column_stack([xs, ys])

if not transform.is_affine:
paths = [transform.transform_path_non_affine(path)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions lib/matplotlib/tests/test_collections.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import io
from types import SimpleNamespace
from datetime import datetime

import numpy as np
from numpy.testing import assert_array_equal, assert_array_almost_equal
Expand Down Expand Up @@ -1181,3 +1182,22 @@ def test_set_offset_units():
off0 = sc.get_offsets()
sc.set_offsets(list(zip(y, d)))
np.testing.assert_allclose(off0, sc.get_offsets())


@image_comparison(baseline_images=["test_check_masked_offsets"],
extensions=["png"], remove_text=True, style="mpl20")
def test_check_masked_offsets():
# Check if masked data is respected by scatter
# Ref: Issue #24545
unmasked_x = [
datetime(2022, 12, 15, 4, 49, 52),
datetime(2022, 12, 15, 4, 49, 53),
datetime(2022, 12, 15, 4, 49, 54),
datetime(2022, 12, 15, 4, 49, 55),
datetime(2022, 12, 15, 4, 49, 56),
]

masked_y = np.ma.array([1, 2, 3, 4, 5], mask=[0, 1, 1, 0, 0])

fig, ax = plt.subplots()
ax.scatter(unmasked_x, masked_y)