10000 Merge pull request #24739 from meeseeksmachine/auto-backport-of-pr-24… · matplotlib/matplotlib@6c225dc · GitHub
[go: up one dir, main page]

Skip to content

Commit 6c225dc

Browse files
authored
Merge pull request #24739 from meeseeksmachine/auto-backport-of-pr-24732-on-v3.6.x
Backport PR #24732 on branch v3.6.x (Use masked stack to preserve mask info)
2 parents 5ef0925 + e1523fd commit 6c225dc

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

lib/matplotlib/collections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def _prepare_points(self):
323323
paths.append(mpath.Path(np.column_stack([xs, ys]), path.codes))
324324
xs = self.convert_xunits(offsets[:, 0])
325325
ys = self.convert_yunits(offsets[:, 1])
326-
offsets = np.column_stack([xs, ys])
326+
offsets = np.ma.column_stack([xs, ys])
327327

328328
if not transform.is_affine:
329329
paths = [transform 10000 .transform_path_non_affine(path)
Loading

lib/matplotlib/tests/test_collections.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import io
22
from types import SimpleNamespace
3+
from datetime import datetime
34

45
import numpy as np
56
from numpy.testing import assert_array_equal, assert_array_almost_equal
@@ -1181,3 +1182,22 @@ def test_set_offset_units():
11811182
off0 = sc.get_offsets()
11821183
sc.set_offsets(list(zip(y, d)))
11831184
np.testing.assert_allclose(off0, sc.get_offsets())
1185+
1186+
1187+
@image_comparison(baseline_images=["test_check_masked_offsets"],
1188+
extensions=["png"], remove_text=True, style="mpl20")
1189+
def test_check_masked_offsets():
1190+
# Check if masked data is respected by scatter
1191+
# Ref: Issue #24545
1192+
unmasked_x = [
1193+
datetime(2022, 12, 15, 4, 49, 52),
1194+
datetime(2022, 12, 15, 4, 49, 53),
1195+
datetime(2022, 12, 15, 4, 49, 54),
1196+
datetime(2022, 12, 15, 4, 49, 55),
1197+
datetime(2022, 12, 15, 4, 49, 56),
1198+
]
1199+
1200+
masked_y = np.ma.array([1, 2, 3, 4, 5], mask=[0, 1, 1, 0, 0])
1201+
1202+
fig, ax = plt.subplots()
1203+
ax.scatter(unmasked_x, masked_y)

0 commit comments

Comments
 (0)
0