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

Commit112a901

Browse files
committed
Make hatch colour an rcParam.
1 parentcb21ba7 commit112a901

18 files changed

+370
-78
lines changed

‎doc/users/dflt_style_changes.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -597,17 +597,20 @@ To restore the previous behavior explicitly pass the keyword argument
597597
Hatching
598598
========
599599

600-
The width of the lines in a hatch pattern is now configurable by the
601-
rcParam `hatch.linewidth`, with a default of 1 point. The old
602-
behavior was different depending on backend:
600+
The color and width of the lines in a hatch pattern are now configurable by the
601+
rcParams `hatch.color` and `hatch.linewidth`, with defaults of black and 1
602+
point, respectively. The old behaviour for the color was to apply the edge
603+
color or use black, depending on the artist; the old behavior for the line
604+
width was different depending on backend:
603605

604606
- PDF: 0.1 pt
605607
- SVG: 1.0 pt
606608
- PS: 1 px
607609
- Agg: 1 px
608610

609-
The old behavior can not be restored across all backends simultaneously, but
610-
can be restored for a single backend by setting::
611+
The old color behavior can not be restored. The old line width behavior can not
612+
be restored across all backends simultaneously, but can be restored for a
613+
single backend by setting::
611614

612615
mpl.rcParams['hatch.linewidth'] = 0.1 # previous pdf hatch linewidth
613616
mpl.rcParams['hatch.linewidth'] = 1.0 # previous svg hatch linewidth
@@ -620,7 +623,7 @@ The behavior of the PS and Agg backends was DPI dependent, thus::
620623
mpl.rcParams['hatch.linewidth'] = 1.0 / dpi # previous ps and Agg hatch linewidth
621624

622625

623-
There is no API level control of the hatch linewidth.
626+
There is no API level control of the hatchcolor orlinewidth.
624627

625628

626629
.. _default_changes_font:

‎lib/matplotlib/backend_bases.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ def __init__(self):
796796
self._linewidth=1
797797
self._rgb= (0.0,0.0,0.0,1.0)
798798
self._hatch=None
799+
self._hatch_color=colors.to_rgba(rcParams['hatch.color'])
799800
self._hatch_linewidth=rcParams['hatch.linewidth']
800801
self._url=None
801802
self._gid=None
@@ -1104,6 +1105,12 @@ def get_hatch_path(self, density=6.0):
11041105
returnNone
11051106
returnPath.hatch(self._hatch,density)
11061107

1108+
defget_hatch_color(self):
1109+
"""
1110+
Gets the color to use for hatching.
1111+
"""
1112+
returnself._hatch_color
1113+
11071114
defget_hatch_linewidth(self):
11081115
"""
11091116
Gets the linewidth to use for hatching.

‎lib/matplotlib/backends/backend_pdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2217,7 +2217,7 @@ def hatch_cmd(self, hatch):
22172217
else:
22182218
return [Name('DeviceRGB'),Op.setcolorspace_nonstroke]
22192219
else:
2220-
hatch_style= (self._rgb,self._fillcolor,hatch)
2220+
hatch_style= (self._hatch_color,self._fillcolor,hatch)
22212221
name=self.file.hatchPattern(hatch_style)
22222222
return [Name('Pattern'),Op.setcolorspace_nonstroke,
22232223
name,Op.setcolor_nonstroke]

‎lib/matplotlib/backends/backend_ps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ def _draw_ps(self, ps, gc, rgbFace, fill=True, stroke=True, command=None):
897897
ifhatch:
898898
hatch_name=self.create_hatch(hatch)
899899
write("gsave\n")
900-
write("[/Pattern [/DeviceRGB]] setcolorspace %f %f %f "%gc.get_rgb()[:3])
900+
write("[/Pattern [/DeviceRGB]] setcolorspace %f %f %f "%gc.get_hatch_color()[:3])
901901
write("%s setcolor fill grestore\n"%hatch_name)
902902

903903
ifstroke:

‎lib/matplotlib/backends/backend_svg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def _get_hatch(self, gc, rgbFace):
349349
"""
350350
ifrgbFaceisnotNone:
351351
rgbFace=tuple(rgbFace)
352-
edge=gc.get_rgb()
352+
edge=gc.get_hatch_color()
353353
ifedgeisnotNone:
354354
edge=tuple(edge)
355355
dictkey= (gc.get_hatch(),rgbFace,edge)

‎lib/matplotlib/mpl-data/stylelib/classic.mplstyle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ patch.force_edgecolor : True
3434
patch.edgecolor : k
3535
patch.antialiased : True # render patches in antialiased (no jaggies)
3636

37+
hatch.color : k
3738
hatch.linewidth : 1.0
3839

3940
hist.bins : 10

‎lib/matplotlib/rcsetup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,7 @@ def validate_animation_writer_path(p):
930930
'patch.antialiased': [True,validate_bool],# antialiased (no jaggies)
931931

932932
## hatch props
933+
'hatch.color': ['k',validate_color],
933934
'hatch.linewidth': [1.0,validate_float],
934935

935936
## Histogram properties
Binary file not shown.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp