8000 FIX: contourf hatches use multiple edgecolors (#28993) · matplotlib/matplotlib@190aa67 · GitHub
[go: up one dir, main page]

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 190aa67

Browse files
authored
FIX: contourf hatches use multiple edgecolors (#28993)
1 parent 9bfc330 commit 190aa67

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

lib/matplotlib/contour.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,12 +1259,16 @@ def draw(self, renderer):
12591259
super().draw(renderer)
12601260
return
12611261
# In presence of hatching, draw contours one at a time.
1262+
edgecolors = self.get_edgecolors()
1263+
if edgecolors.size == 0:
1264+
edgecolors = ("none",)
12621265
for idx in range(n_paths):
12631266
with cbook._setattr_cm(self, _paths=[paths[idx]]), self._cm_set(
12641267
hatch=self.hatches[idx % len(self.hatches)],
12651268
array=[self.get_array()[idx]],
12661269
linewidths=[self.get_linewidths()[idx % len(self.get_linewidths())]],
12671270
linestyles=[self.get_linestyles()[idx % len(self.get_linestyles())]],
1271+
edgecolors=edgecolors[idx % len(edgecolors)],
12681272
):
12691273
super().draw(renderer)
12701274

Loading

lib/matplotlib/tests/test_contour.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ def test_given_colors_levels_and_extends():
171171
plt.colorbar(c, ax=ax)
172172

173173

174+
@image_comparison(['contourf_hatch_colors'],
175+
remove_text=True, style='mpl20', extensions=['png'])
176+
def test_hatch_colors():
177+
fig, ax = plt.subplots()
178+
cf = ax.contourf([[0, 1], [1, 2]], hatches=['-', '/', '\\', '//'], cmap='gray')
179+
cf.set_edgecolors(["blue", "grey", "yellow", "red"])
180+
181+
174182
@pytest.mark.parametrize('color, extend', [('darkred', 'neither'),
175183
('darkred', 'both'),
176184
(('r', 0.5), 'neither'),

0 commit comments

Comments
 (0)
0