Skip to content

Commit fe027ed

Browse files
committed
made suggested changes
1 parent 438c319 commit fe027ed

10 files changed

+42
-38
lines changed

lib/matplotlib/backend_bases.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ def draw_markers(self, gc, marker_path, marker_trans, path,
204204
rgbFace)
205205

206206
def draw_path_collection(self, gc, master_transform, paths, all_transforms,
207-
offsets, offset_trans, facecolors, edgecolors, hatchcolors,
207+
offsets, offset_trans, facecolors, edgecolors,
208208
linewidths, linestyles, antialiaseds, urls,
209-
offset_position):
209+
offset_position, hatchcolors=[]):
210210
"""
211211
Draw a collection of *paths*.
212212
@@ -250,7 +250,7 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
250250

251251
def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
252252
coordinates, offsets, offsetTrans, facecolors,
253-
antialiased, edgecolors, hatchcolors):
253+
antialiased, edgecolors, hatchcolors=[]):
254254
"""
255255
Draw a quadmesh.
256256
@@ -267,7 +267,7 @@ def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
267267

268268
return self.draw_path_collection(
269269
gc, master_transform, paths, [], offsets, offsetTrans, facecolors,
270-
edgecolors, hatchcolors, linewidths, [], [antialiased], [None], 'screen')
270+
edgecolors, linewidths, [], [antialiased], [None], 'screen', hatchcolors)
271271

272272
def draw_gouraud_triangles(self, gc, triangles_array, colors_array,
273273
transform):

lib/matplotlib/backend_bases.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ class RendererBase:
5858
offset_trans: Transform,
5959
facecolors: ColorType | Sequence[ColorType],
6060
edgecolors: ColorType | Sequence[ColorType],
61-
hatchcolors: ColorType | Sequence[ColorType],
6261
linewidths: float | Sequence[float],
6362
linestyles: LineStyleType | Sequence[LineStyleType],
6463
antialiaseds: bool | Sequence[bool],
6564
urls: str | Sequence[str],
6665
offset_position: Any,
66+
hatchcolors: ColorType | Sequence[ColorType],
6767
) -> None: ...
6868
def draw_quad_mesh(
6969
self,

lib/matplotlib/backends/backend_pdf.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -2025,9 +2025,9 @@ def draw_path(self, gc, path, transform, rgbFace=None):
20252025
self.file.output(self.gc.paint())
20262026

20272027
def draw_path_collection(self, gc, master_transform, paths, all_transforms,
2028-
offsets, offset_trans, facecolors, edgecolors, hatchcolors,
2028+
offsets, offset_trans, facecolors, edgecolors,
20292029
linewidths, linestyles, antialiaseds, urls,
2030-
offset_position):
2030+
offset_position, hatchcolors=[]):
20312031
# We can only reuse the objects if the presence of fill and
20322032
# stroke (and the amount of alpha for each) is the same for
20332033
# all of them
@@ -2067,9 +2067,9 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
20672067
if (not can_do_optimization) or (not should_do_optimization):
20682068
return RendererBase.draw_path_collection(
20692069
self, gc, master_transform, paths, all_transforms,
2070-
offsets, offset_trans, facecolors, edgecolors, hatchcolors,
2070+
offsets, offset_trans, facecolors, edgecolors,
20712071
linewidths, linestyles, antialiaseds, urls,
2072-
offset_position)
2072+
offset_position, hatchcolors)
20732073

20742074
padding = np.max(linewidths)
20752075
path_codes = []

lib/matplotlib/backends/backend_ps.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,9 @@ def draw_markers(
512512

513513
@_log_if_debug_on
514514
def draw_path_collection(self, gc, master_transform, paths, all_transforms,
515-
offsets, offset_trans, facecolors, edgecolors, hatchcolors,
515+
offsets, offset_trans, facecolors, edgecolors,
516516
linewidths, linestyles, antialiaseds, urls,
517-
offset_position):
517+
offset_position, hatchcolors=[]):
518518
# Is the optimization worth it? Rough calculation:
519519
# cost of emitting a path in-line is
520520
# (len_path + 2) * uses_per_path
@@ -528,9 +528,9 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
528528
if not should_do_optimization:
529529
return RendererBase.draw_path_collection(
530530
self, gc, master_transform, paths, all_transforms,
531-
offsets, offset_trans, facecolors, edgecolors, hatchcolors,
531+
offsets, offset_trans, facecolors, edgecolors,
532532
linewidths, linestyles, antialiaseds, urls,
533-
offset_position)
533+
offset_position, hatchcolors)
534534

535535
path_codes = []
536536
for i, (path, transform) in enumerate(self._iter_collection_raw_paths(

lib/matplotlib/backends/backend_svg.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -733,9 +733,9 @@ def draw_markers(
733733
writer.end('g')
734734

735735
def draw_path_collection(self, gc, master_transform, paths, all_transforms,
736-
offsets, offset_trans, facecolors, edgecolors, hatchcolors,
736+
offsets, offset_trans, facecolors, edgecolors,
737737
linewidths, linestyles, antialiaseds, urls,
738-
offset_position):
738+
offset_position, hatchcolors=[]):
739739
# Is the optimization worth it? Rough calculation:
740740
# cost of emitting a path in-line is
741741
# (len_path + 5) * uses_per_path
@@ -749,9 +749,9 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
749749
if not should_do_optimization:
750750
return super().draw_path_collection(
751751
gc, master_transform, paths, all_transforms,
752-
offsets, offset_trans, facecolors, edgecolors, hatchcolors,
752+
offsets, offset_trans, facecolors, edgecolors,
753753
linewidths, linestyles, antialiaseds, urls,
754-
offset_position)
754+
offset_position, hatchcolors)
755755

756756
writer = self.writer
757757
path_codes = []

lib/matplotlib/backends/backend_template.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ def draw_path(self, gc, path, transform, rgbFace=None):
6464
# performance will probably want to implement it
6565
# def draw_path_collection(self, gc, master_transform, paths,
6666
# all_transforms, offsets, offset_trans,
67-
# facecolors, edgecolors, hatchcolors,
68-
# linewidths, linestyles, antialiaseds):
67+
# facecolors, edgecolors, linewidths, linestyles,
68+
# antialiaseds):
6969
# pass
7070

7171
# draw_quad_mesh is optional, and we get more correct

lib/matplotlib/collections.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -420,18 +420,19 @@ def draw(self, renderer):
420420
renderer.draw_path_collection(
421421
gc, transform.frozen(), ipaths,
422422
self.get_transforms(), offsets, offset_trf,
423-
[mcolors.to_rgba("none")], self._gapcolor, self.get_hatchcolor(),
423+
[mcolors.to_rgba("none")], self._gapcolor,
424424
self._linewidths, ilinestyles,
425425
self._antialiaseds, self._urls,
426-
"screen")
426+
"screen", self.get_hatchcolor())
427427

428428
renderer.draw_path_collection(
429429
gc, transform.frozen(), paths,
430430
self.get_transforms(), offsets, offset_trf,
431-
self.get_facecolor(), self.get_edgecolor(), self.get_hatchcolor(),
431+
self.get_facecolor(), self.get_edgecolor(),
432432
self._linewidths, self._linestyles,
433433
self._antialiaseds, self._urls,
434-
"screen") # offset_position, kept for backcompat.
434+
"screen", # offset_position, kept for backcompat
435+
self.get_hatchcolor())
435436

436437
gc.restore()
437438
renderer.close_group(self.__class__.__name__)
@@ -812,13 +813,13 @@ def _set_edgecolor(self, c):
812813
if cbook._str_lower_equal(c, 'face'):
813814
self._edgecolors = 'face'
814815
if self._original_hatchcolor is None:
815-
self._set_hatchcolor('black')
816+
self._set_hatchcolor(mpl.rcParams['patch.edgecolor'])
816817
self.stale = True
817818
return
818819
self._edgecolors = mcolors.to_rgba_array(c, self._alpha)
819820
if self._original_hatchcolor is None:
820821
if isinstance(c, str) and c == 'none':
821-
self._set_hatchcolor('black')
822+
self._set_hatchcolor(mpl.rcParams['patch.edgecolor'])
822823
else:
823824
self._hatchcolors = self._edgecolors
824825
self.stale = True
@@ -846,11 +847,12 @@ def _set_hatchcolor(self, c):
846847
if c == "inherit":
847848
if self._original_edgecolor is not None:
848849
c = self._original_edgecolor
850+
if isinstance(c, str) and c in ('none', 'face'):
851+
c = mpl.rcParams["patch.edgecolor"]
849852
else:
850853
c = mpl.rcParams["patch.edgecolor"]
851-
852-
if isinstance(c, str) and c in ('none', 'face'):
853-
c = 'black'
854+
else:
855+
self._original_hatchcolor = c
854856

855857
self._hatchcolors = mcolors.to_rgba_array(c, self._alpha)
856858
self.stale = True

lib/matplotlib/patches.py

+2
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ def _set_hatchcolor(self, color):
429429
color = self._original_edgecolor
430430
else:
431431
color = mpl.rcParams['patch.edgecolor']
432+
else:
433+
self._original_hatchcolor = color
432434
self._hatch_color = colors.to_rgba(color, self._alpha)
433435
self.stale = True
434436

src/_backend_agg.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ class RendererAgg
171171
agg::trans_affine &offset_trans,
172172
ColorArray &facecolors,
173173
ColorArray &edgecolors,
174-
ColorArray &hatchcolors,
175174
LineWidthArray &linewidths,
176175
DashesVector &linestyles,
177-
AntialiasedArray &antialiaseds);
176+
AntialiasedArray &antialiaseds,
177+
ColorArray &hatchcolors);
178178

179179
template <class CoordinateArray, class OffsetArray, class ColorArray>
180180
void draw_quad_mesh(GCAgg &gc,
@@ -1042,10 +1042,10 @@ inline void RendererAgg::draw_path_collection(GCAgg &gc,
10421042
agg::trans_affine &offset_trans,
10431043
ColorArray &facecolors,
10441044
ColorArray &edgecolors,
1045-
ColorArray &hatchcolors,
10461045
LineWidthArray &linewidths,
10471046
DashesVector &linestyles,
1048-
AntialiasedArray &antialiaseds)
1047+
AntialiasedArray &antialiaseds,
1048+
ColorArray &hatchcolors)
10491049
{
10501050
_draw_path_collection_generic(gc,
10511051
master_transform,

src/_backend_agg_wrapper.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ PyRendererAgg_draw_path_collection(PyRendererAgg *self, PyObject *args)
306306
PyObject *offset_position; // offset position is no longer used
307307

308308
if (!PyArg_ParseTuple(args,
309-
"O&O&O&O&O&O&O&O&O&O&O&O&OO:draw_path_collection",
309+
"O&O&O&O&O&O&O&O&O&O&O&OOO&:draw_path_collection",
310310
&convert_gcagg,
311311
&gc,
312312
&convert_trans_affine,
@@ -323,16 +323,16 @@ PyRendererAgg_draw_path_collection(PyRendererAgg *self, PyObject *args)
323323
&facecolors,
324324
&convert_colors,
325325
&edgecolors,
326-
&convert_colors,
327-
&hatchcolors,
328326
&linewidths.converter,
329327
&linewidths,
330328
&convert_dashes_vector,
331329
&dashes,
332330
&antialiaseds.converter,
333331
&antialiaseds,
334332
&ignored,
335-
&offset_position)) {
333+
&offset_position,
334+
&convert_colors,
335+
&hatchcolors)) {
336336
return NULL;
337337
}
338338

@@ -345,10 +345,10 @@ PyRendererAgg_draw_path_collection(PyRendererAgg *self, PyObject *args)
345345
offset_trans,
346346
facecolors,
347347
edgecolors,
348-
hatchcolors,
349348
linewidths,
350349
dashes,
351-
antialiaseds)));
350+
antialiaseds,
351+
hatchcolors)));
352352

353353
Py_RETURN_NONE;
354354
}

0 commit comments

Comments
 (0)