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

Commitb9ac0fb

Browse files
committed
Made suggested changes
1 parentfee895b commitb9ac0fb

File tree

11 files changed

+31
-25
lines changed

11 files changed

+31
-25
lines changed

‎galleries/examples/shapes_and_collections/hatchcolor_demo.py‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@
33
Hatchcolor Demo
44
===============
55
6+
The color of the hatch can be set using the *hatchcolor* parameter. The following
7+
examples show how to use the *hatchcolor* parameter to set the color of the hatch
8+
in `~.patches.Patch` and `~.collections.Collection`.
9+
10+
See also :doc:`/gallery/shapes_and_collections/hatch_demo` for more usage examples
11+
of hatching.
12+
613
Patch Hatchcolor
714
----------------
815
916
This example shows how to use the *hatchcolor* parameter to set the color of
10-
the hatch. The *hatchcolor* parameter is available for `~.patches.Patch`,
11-
child classes of Patch, and methods that pass through to Patch.
17+
the hatch in a rectangle and a bar plot. The *hatchcolor* parameter is available for
18+
`~.patches.Patch`,child classes of Patch, and methods that pass through to Patch.
1219
"""
1320

1421
importmatplotlib.pyplotasplt
@@ -62,19 +69,13 @@
6269
facecolor="none",
6370
edgecolor="gray",
6471
linewidth=2,
65-
marker="h",# Use hexagon as marker
72+
marker="s",# Use hexagon as marker
6673
hatch="xxx",
6774
hatchcolor=colors,
6875
)
6976
ax.set_xlim(0,1)
7077
ax.set_ylim(0,1)
7178

72-
# Remove ticks and labels
73-
ax.set_xticks([])
74-
ax.set_yticks([])
75-
ax.set_xticklabels([])
76-
ax.set_yticklabels([])
77-
7879
plt.show()
7980

8081
# %%

‎lib/matplotlib/backend_bases.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
221221
and *hatchcolors* are lists that set the corresponding properties.
222222
223223
.. versionadded:: 3.11
224-
Allowing *hatchcolors* to be specified.
224+
Allow *hatchcolors* to be specified.
225225
226226
*offset_position* is unused now, but the argument is kept for
227227
backwards compatibility.
@@ -244,7 +244,7 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
244244
forxo,yo,path_id,gc0,rgbFaceinself._iter_collection(
245245
gc,list(path_ids),offsets,offset_trans,
246246
facecolors,edgecolors,linewidths,linestyles,
247-
antialiaseds,urls,offset_position,hatchcolors):
247+
antialiaseds,urls,offset_position,hatchcolors=hatchcolors):
248248
path,transform=path_id
249249
# Only apply another translation if we have an offset, else we
250250
# reuse the initial transform.
@@ -258,7 +258,7 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
258258

259259
defdraw_quad_mesh(self,gc,master_transform,meshWidth,meshHeight,
260260
coordinates,offsets,offsetTrans,facecolors,
261-
antialiased,edgecolors,hatchcolors=None):
261+
antialiased,edgecolors,*,hatchcolors=None):
262262
"""
263263
Draw a quadmesh.
264264
@@ -346,7 +346,7 @@ def _iter_collection_uses_per_path(self, paths, all_transforms,
346346

347347
def_iter_collection(self,gc,path_ids,offsets,offset_trans,facecolors,
348348
edgecolors,linewidths,linestyles,
349-
antialiaseds,urls,offset_position,hatchcolors):
349+
antialiaseds,urls,offset_position,*,hatchcolors):
350350
"""
351351
Helper method (along with `_iter_collection_raw_paths`) to implement
352352
`draw_path_collection` in a memory-efficient manner.

‎lib/matplotlib/backend_bases.pyi‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class RendererBase:
7878
facecolors:Sequence[ColorType],
7979
antialiased:bool,
8080
edgecolors:Sequence[ColorType]|ColorType|None,
81+
*,
8182
hatchcolors:Sequence[ColorType]|ColorType|None=None,
8283
)->None: ...
8384
defdraw_gouraud_triangles(

‎lib/matplotlib/backends/backend_pdf.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2091,7 +2091,7 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
20912091
forxo,yo,path_id,gc0,rgbFaceinself._iter_collection(
20922092
gc,path_codes,offsets,offset_trans,
20932093
facecolors,edgecolors,linewidths,linestyles,
2094-
antialiaseds,urls,offset_position,hatchcolors):
2094+
antialiaseds,urls,offset_position,hatchcolors=hatchcolors):
20952095

20962096
self.check_gc(gc0,rgbFace)
20972097
dx,dy=xo-lastx,yo-lasty

‎lib/matplotlib/backends/backend_ps.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
711711
forxo,yo,path_id,gc0,rgbFaceinself._iter_collection(
712712
gc,path_codes,offsets,offset_trans,
713713
facecolors,edgecolors,linewidths,linestyles,
714-
antialiaseds,urls,offset_position,hatchcolors):
714+
antialiaseds,urls,offset_position,hatchcolors=hatchcolors):
715715
ps=f"{xo:g}{yo:g}{path_id}"
716716
self._draw_ps(ps,gc0,rgbFace)
717717

‎lib/matplotlib/backends/backend_svg.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
772772
forxo,yo,path_id,gc0,rgbFaceinself._iter_collection(
773773
gc,path_codes,offsets,offset_trans,
774774
facecolors,edgecolors,linewidths,linestyles,
775-
antialiaseds,urls,offset_position,hatchcolors):
775+
antialiaseds,urls,offset_position,hatchcolors=hatchcolors):
776776
url=gc0.get_url()
777777
ifurlisnotNone:
778778
writer.start('a',attrib={'xlink:href':url})

‎lib/matplotlib/collections.py‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ def draw(self, renderer):
454454
path_ids=renderer._iter_collection_raw_paths(
455455
transform.frozen(),ipaths,self.get_transforms())
456456
forxo,yo,path_id,gc0,rgbFaceinrenderer._iter_collection(
457-
gc,list(path_ids),*args
457+
gc,list(path_ids),*args,hatchcolors=self.get_hatchcolor(),
458458
):
459459
path,transform=path_id
460460
ifxo!=0oryo!=0:
@@ -474,7 +474,7 @@ def draw(self, renderer):
474474
path_ids=renderer._iter_collection_raw_paths(
475475
transform.frozen(),paths,self.get_transforms())
476476
forxo,yo,path_id,gc0,rgbFaceinrenderer._iter_collection(
477-
gc,list(path_ids),*args
477+
gc,list(path_ids),*args,hatchcolors=self.get_hatchcolor(),
478478
):
479479
path,transform=path_id
480480
ifxo!=0oryo!=0:
@@ -802,14 +802,17 @@ def set_color(self, c):
802802
"""
803803
Set the edgecolor, facecolor and hatchcolor.
804804
805+
.. versionchanged:: 3.11
806+
Now sets the hatchcolor as well.
807+
805808
Parameters
806809
----------
807810
c : :mpltype:`color` or list of RGBA tuples
808811
809812
See Also
810813
--------
811-
Collection.set_facecolor, Collection.set_edgecolor
812-
For setting theedge or face color individually.
814+
Collection.set_facecolor, Collection.set_edgecolor, Collection.set_hatchcolor
815+
For setting thefacecolor, edgecolor, and hatchcolor individually.
813816
"""
814817
self.set_facecolor(c)
815818
self.set_edgecolor(c)
@@ -2535,7 +2538,7 @@ def draw(self, renderer):
25352538
# Backends expect flattened rgba arrays (n*m, 4) for fc and ec
25362539
self.get_facecolor().reshape((-1,4)),
25372540
self._antialiased,self.get_edgecolors().reshape((-1,4)),
2538-
self.get_hatchcolor().reshape((-1,4)))
2541+
hatchcolors=self.get_hatchcolor().reshape((-1,4)))
25392542
gc.restore()
25402543
renderer.close_group(self.__class__.__name__)
25412544
self.stale=False

‎lib/matplotlib/collections.pyi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Collection(colorizer.ColorizingArtist):
2121
*,
2222
edgecolors:ColorType|Sequence[ColorType]|None= ...,
2323
facecolors:ColorType|Sequence[ColorType]|None= ...,
24-
hatchcolors:ColorType|Sequence[ColorType]|None= ...,
24+
hatchcolors:ColorType|Sequence[ColorType]|Literal["edge"]|None= ...,
2525
linewidths:float|Sequence[float]|None= ...,
2626
linestyles:LineStyleType|Sequence[LineStyleType]= ...,
2727
capstyle:CapStyleType|None= ...,

‎lib/matplotlib/patches.pyi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Patch(artist.Artist):
2525
fill:bool= ...,
2626
capstyle:CapStyleType|None= ...,
2727
joinstyle:JoinStyleType|None= ...,
28-
hatchcolor:ColorType|None= ...,
28+
hatchcolor:ColorType|Literal["edge"]|None= ...,
2929
**kwargs,
3030
)->None: ...
3131
defget_verts(self)->ArrayLike: ...

‎lib/matplotlib/tests/test_backend_bases.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def check(master_transform, paths, all_transforms,
3838
gc,range(len(raw_paths)),offsets,
3939
transforms.AffineDeltaTransform(master_transform),
4040
facecolors,edgecolors, [], [], [False],
41-
[],'screen', [])]
41+
[],'screen',hatchcolors=[])]
4242
uses=rb._iter_collection_uses_per_path(
4343
paths,all_transforms,offsets,facecolors,edgecolors)
4444
ifraw_paths:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp