Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit2916646

Browse files
committed
Add support for match_original patch drawing
1 parent3bc666b commit2916646

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
lines changed

‎lib/matplotlib/collections.py

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -423,13 +423,31 @@ def draw(self, renderer):
423423
self._antialiaseds,self._urls,
424424
"screen")
425425

426-
renderer.draw_path_collection(
427-
gc,transform.frozen(),paths,
428-
self.get_transforms(),offsets,offset_trf,
429-
self.get_facecolor(),self.get_edgecolor(),
430-
self._linewidths,self._linestyles,
431-
self._antialiaseds,self._urls,
432-
"screen")# offset_position, kept for backcompat.
426+
fcolor=itertools.cycle(facecolors)iffacecolors.any() \
427+
elseitertools.repeat([])
428+
ecolor=itertools.cycle(edgecolors)ifedgecolors.any() \
429+
elseitertools.repeat([])
430+
lwidth=itertools.cycle(self._linewidths)
431+
lstyle=itertools.cycle(self._linestyles)
432+
antialiased=itertools.cycle(self._antialiaseds)
433+
434+
ifself._match_original:
435+
foridxinrange(len(paths)):
436+
gc.set_hatch(self._hatch[idx])
437+
renderer.draw_path_collection(
438+
gc,transform.frozen(), [paths[idx]],
439+
self.get_transforms(),offsets,offset_trf,
440+
[next(fcolor)], [next(ecolor)], [next(lwidth)], [next(lstyle)],
441+
[next(antialiased)],self._urls,
442+
"screen")# offset_position, kept for backcompat.
443+
else:
444+
renderer.draw_path_collection(
445+
gc,transform.frozen(),paths,
446+
self.get_transforms(),offsets,offset_trf,
447+
self.get_facecolor(),self.get_edgecolor(),
448+
self._linewidths,self._linestyles,
449+
self._antialiaseds,self._urls,
450+
"screen")
433451

434452
gc.restore()
435453
renderer.close_group(self.__class__.__name__)
@@ -1844,22 +1862,21 @@ def __init__(self, patches, *, match_original=False, **kwargs):
18441862
a call to `~.ScalarMappable.set_array`), at draw time a call to scalar
18451863
mappable will be made to set the face colors.
18461864
"""
1865+
self._match_original=False
18471866

18481867
ifmatch_original:
1868+
self._match_original=True
18491869
kwargs['facecolors']= [p.get_facecolor()forpinpatches]
18501870
kwargs['linewidths']= [p.get_linewidth()forpinpatches]
18511871
kwargs['linestyles']= [p.get_linestyle()forpinpatches]
18521872
kwargs['antialiaseds']= [p.get_antialiased()forpinpatches]
1873+
kwargs['hatch']= [p.get_hatch()forpinpatches]
18531874

18541875
# Edgecolors are handled separately because are defaulted to None
18551876
# and the Hatch colors depend on them.
1856-
ifany(p._original_edgecolorisnotNoneforpinpatches):
1877+
ifall(p._original_edgecolorisnotNoneforpinpatches):
18571878
kwargs["edgecolors"]= [p.get_edgecolor()forpinpatches]
18581879

1859-
# Using the hatch of only the first patch
1860-
ifpatches:
1861-
kwargs['hatch']=patches[0].get_hatch()
1862-
18631880
super().__init__(**kwargs)
18641881

18651882
self.set_paths(patches)

‎lib/matplotlib/hatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def __init__(self, hatch, density):
180180

181181

182182
def_validate_hatch_pattern(hatch):
183-
valid_hatch_patterns=set(r'-+|/\xXoO.*')
183+
valid_hatch_patterns=set(r'-+|/\xXoO.*').union({None})
184184
ifhatchisnotNone:
185185
invalids=set(hatch).difference(valid_hatch_patterns)
186186
ifinvalids:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp