Skip to content

FIX: pcolor/pcolormesh honour edgecolors kwarg when facecolors is set 'none' #12226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 14 additions & 0 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5789,6 +5789,13 @@ def pcolor(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
corners = (minx, miny), (maxx, maxy)
self.update_datalim(corners)
self.autoscale_view()
# The following block of code addresses github issue #1302
for face_color in ['facecolor', 'facecolors']:
try:
if kwargs.get(face_color).lower() == 'none':
collection._is_stroked = False
except AttributeError:
pass
return collection

@_preprocess_data(label_namer=None)
Expand Down Expand Up @@ -6002,6 +6009,13 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
corners = (minx, miny), (maxx, maxy)
self.update_datalim(corners)
self.autoscale_view()
# The following block of code addresses github issue #1302
for face_color in ['facecolor', 'facecolors']:
try:
if kwargs.get(face_color).lower() == 'none':
collection._is_stroked = False
except AttributeError:
pass
return collection

@_preprocess_data(label_namer=None)
Expand Down
16 changes: 16 additions & 0 deletions lib/matplotlib/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,3 +922,19 @@ def test_relim():
ax.relim()
ax.autoscale()
assert ax.get_xlim() == ax.get_ylim() == (0, 1)


def test_edgefacecolor_pcolor_pcolormesh():
# Test that pcolor/pcolormesh honours edgecolors kwarg when facecolors
# is set to 'none' (github issue #1302 and fixed by PR #12226).
fig, ax = plt.subplots(2)
im0 = ax[0].pcolor(np.arange(12).reshape(4, 3),
edgecolors='red', facecolors='none')
im1 = ax[1].pcolormesh(np.arange(12).reshape(4, 3),
edgecolors='red', facecolors='none')
# triggering draw() to make sure that the edges of the mesh are drawn.
fig.canvas.draw()
np.testing.assert_equal(im0.get_edgecolors(),
np.array([[1., 0., 0., 1.]]))
np.testing.assert_equal(im1.get_edgecolors(),
np.array([[1., 0., 0., 1.]]))