Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eaf830f

Browse filesBrowse files
committed
Allow using masked array as offsets
1 parent a9ba9d5 commit eaf830f
Copy full SHA for eaf830f

File tree

Expand file treeCollapse file tree

2 files changed

+14
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-3
lines changed

‎lib/matplotlib/collections.py

Copy file name to clipboardExpand all lines: lib/matplotlib/collections.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,9 @@ def set_offsets(self, offsets):
545545
offsets = np.asanyarray(offsets)
546546
if offsets.shape == (2,): # Broadcast (2,) -> (1, 2) but nothing else.
547547
offsets = offsets[None, :]
548-
self._offsets = np.column_stack(
549-
(np.asarray(self.convert_xunits(offsets[:, 0]), float),
550-
np.asarray(self.convert_yunits(offsets[:, 1]), float)))
548+
self._offsets = np.ma.column_stack(
549+
(np.asanyarray(self.convert_xunits(offsets[:, 0]), float),
550+
np.asanyarray(self.convert_yunits(offsets[:, 1]), float)))
551551
self.stale = True
552552

553553
def get_offsets(self):

‎lib/matplotlib/tests/test_collections.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_collections.py
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,3 +1149,14 @@ def test_check_masked_offsets():
11491149

11501150
fig, ax = plt.subplots()
11511151
ax.scatter(unmasked_x, masked_y)
1152+
1153+
1154+
def test_masked_set_offsets():
1155+
x = np.ma.array([1, 2, 3, 4, 5], mask=[0, 0, 1, 1, 0])
1156+
y = np.arange(1, 6)
1157+
1158+
fig, ax = plt.subplots()
1159+
scat = ax.scatter(x, y)
1160+
x += 1
1161+
scat.set_offsets(np.ma.column_stack([x, y]))
1162+
assert np.ma.is_masked(scat.get_offsets())

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.