Skip to content

Commit 4971311

Browse files
committed
Use the mask from the stored array
1 parent b741db8 commit 4971311

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/matplotlib/collections.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,8 +2098,10 @@ def _convert_mesh_to_triangles(self, coordinates):
20982098
], axis=2).reshape((-1, 3, 2))
20992099

21002100
c = self.get_facecolor().reshape((*coordinates.shape[:2], 4))
2101-
mask = c[..., 3] == 0
2102-
c[mask, 3] = np.nan
2101+
z = self.get_array()
2102+
mask = z.mask if np.ma.is_masked(z) else None
2103+
if mask is not None:
2104+
c[mask, 3] = np.nan
21032105
c_a = c[:-1, :-1]
21042106
c_b = c[:-1, 1:]
21052107
c_c = c[1:, 1:]
@@ -2111,8 +2113,8 @@ def _convert_mesh_to_triangles(self, coordinates):
21112113
c_c, c_d, c_center,
21122114
c_d, c_a, c_center,
21132115
], axis=2).reshape((-1, 3, 4))
2114-
mask = np.isnan(colors[..., 2, 3])
2115-
return triangles[~mask], colors[~mask]
2116+
tmask = np.isnan(colors[..., 2, 3])
2117+
return triangles[~tmask], colors[~tmask]
21162118

21172119
@artist.allow_rasterization
21182120
def draw(self, renderer):

0 commit comments

Comments
 (0)