Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c5e9583

Browse files
committed
Fix hatchcolors argument support in third-party backends
1 parent 7e46707 commit c5e9583

File tree

1 file changed

+36
-14
lines changed

1 file changed

+36
-14
lines changed

lib/matplotlib/collections.py

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -437,23 +437,45 @@ def draw(self, renderer):
437437
if self._gapcolor is not None:
438438
# First draw paths within the gaps.
439439
ipaths, ilinestyles = self._get_inverse_paths_linestyles()
440-
args = [gc, transform.frozen(), ipaths, self.get_transforms(),
441-
offsets, offset_trf, [mcolors.to_rgba("none")],
442-
self._gapcolor, self._linewidths, ilinestyles,
443-
self._antialiaseds, self._urls, "screen"]
444-
if hatchcolors_arg_supported:
445-
args.append(self.get_hatchcolor())
440+
args = [offsets, offset_trf, [mcolors.to_rgba("none")], self._gapcolor,
441+
self._linewidths, ilinestyles, self._antialiaseds, self._urls,
442+
"screen", self.get_hatchcolor()]
446443

447-
renderer.draw_path_collection(*args)
444+
if hatchcolors_arg_supported:
445+
renderer.draw_path_collection(gc, transform.frozen(), ipaths,
446+
self.get_transforms(), *args)
447+
else:
448+
# If the renderer does not support the hatchcolors argument,
449+
# iterate over the paths and draw them one by one.
450+
path_ids = renderer._iter_collection_raw_paths(
451+
transform.frozen(), ipaths, self.get_transforms())
452+
for xo, yo, path_id, gc0, rgbFace in renderer._iter_collection(
453+
gc, list(path_ids), *args
454+
):
455+
path, transform = path_id
456+
if xo != 0 or yo != 0:
457+
transform = transform.frozen()
458+
transform.translate(xo, yo)
459+
renderer.draw_path(gc0, path, transform, rgbFace)
460+
461+
args = [offsets, offset_trf, self.get_facecolor(), self.get_edgecolor(),
462+
self._linewidths, self._linestyles, self._antialiaseds, self._urls,
463+
"screen", self.get_hatchcolor()]
448464

449-
args = [gc, transform.frozen(), paths, self.get_transforms(),
450-
offsets, offset_trf, self.get_facecolor(),
451-
self.get_edgecolor(), self._linewidths, self._linestyles,
452-
self._antialiaseds, self._urls, "screen"]
453465
if hatchcolors_arg_supported:
454-
args.append(self.get_hatchcolor())
455-
456-
renderer.draw_path_collection(*args)
466+
renderer.draw_path_collection(gc, transform.frozen(), paths,
467+
self.get_transforms(), *args)
468+
else:
469+
path_ids = renderer._iter_collection_raw_paths(
470+
transform.frozen(), paths, self.get_transforms())
471+
for xo, yo, path_id, gc0, rgbFace in renderer._iter_collection(
472+
gc, list(path_ids), *args
473+
):
474+
path, transform = path_id
475+
if xo != 0 or yo != 0:
476+
transform = transform.frozen()
477+
transform.translate(xo, yo)
478+
renderer.draw_path(gc0, path, transform, rgbFace)
457479

458480
gc.restore()
459481
renderer.close_group(self.__class__.__name__)

0 commit comments

Comments
 (0)