@@ -731,7 +731,7 @@ def __init__(self, filename, metadata=None):
731731self ._soft_mask_states = {}
732732self ._soft_mask_seq = (Name (f'SM{ i } ' )for i in itertools .count (1 ))
733733self ._soft_mask_groups = []
734- self .hatchPatterns = {}
734+ self ._hatch_patterns = {}
735735self ._hatch_pattern_seq = (Name (f'H{ i } ' )for i in itertools .count (1 ))
736736self .gouraudTriangles = []
737737
@@ -1534,26 +1534,29 @@ def _write_soft_mask_groups(self):
15341534
15351535def hatchPattern (self ,hatch_style ):
15361536# The colors may come in as numpy arrays, which aren't hashable
1537- if hatch_style is not None :
1538- edge ,face ,hatch = hatch_style
1539- if edge is not None :
1540- edge = tuple (edge )
1541- if face is not None :
1542- face = tuple (face )
1543- hatch_style = (edge ,face ,hatch )
1544-
1545- pattern = self .hatchPatterns .get (hatch_style ,None )
1537+ edge ,face ,hatch ,lw = hatch_style
1538+ if edge is not None :
1539+ edge = tuple (edge )
1540+ if face is not None :
1541+ face = tuple (face )
1542+ hatch_style = (edge ,face ,hatch ,lw )
1543+
1544+ pattern = self ._hatch_patterns .get (hatch_style ,None )
15461545if pattern is not None :
15471546return pattern
15481547
15491548name = next (self ._hatch_pattern_seq )
1550- self .hatchPatterns [hatch_style ]= name
1549+ self ._hatch_patterns [hatch_style ]= name
15511550return name
15521551
1552+ hatchPatterns = _api .deprecated ("3.10" )(property (lambda self : {
1553+ k : (e ,f ,h )for k , (e ,f ,h ,l )in self ._hatch_patterns .items ()
1554+ }))
1555+
15531556def writeHatches (self ):
15541557hatchDict = dict ()
15551558sidelen = 72.0
1556- for hatch_style ,name in self .hatchPatterns .items ():
1559+ for hatch_style ,name in self ._hatch_patterns .items ():
15571560ob = self .reserveObject ('hatch pattern' )
15581561hatchDict [name ]= ob
15591562res = {'Procsets' :
@@ -1568,7 +1571,7 @@ def writeHatches(self):
15681571# Change origin to match Agg at top-left.
15691572'Matrix' : [1 ,0 ,0 ,1 ,0 ,self .height * 72 ]})
15701573
1571- stroke_rgb ,fill_rgb ,hatch = hatch_style
1574+ stroke_rgb ,fill_rgb ,hatch , lw = hatch_style
15721575self .output (stroke_rgb [0 ],stroke_rgb [1 ],stroke_rgb [2 ],
15731576Op .setrgb_stroke )
15741577if fill_rgb is not None :
@@ -1577,7 +1580,7 @@ def writeHatches(self):
157715800 ,0 ,sidelen ,sidelen ,Op .rectangle ,
15781581Op .fill )
15791582
1580- self .output (mpl . rcParams [ 'hatch.linewidth' ] ,Op .setlinewidth )
1583+ self .output (lw ,Op .setlinewidth )
15811584
15821585self .output (* self .pathOperations (
15831586Path .hatch (hatch ),
@@ -2508,14 +2511,14 @@ def alpha_cmd(self, alpha, forced, effective_alphas):
25082511name = self .file .alphaState (effective_alphas )
25092512return [name ,Op .setgstate ]
25102513
2511- def hatch_cmd (self ,hatch ,hatch_color ):
2514+ def hatch_cmd (self ,hatch ,hatch_color , hatch_linewidth ):
25122515if not hatch :
25132516if self ._fillcolor is not None :
25142517return self .fillcolor_cmd (self ._fillcolor )
25152518else :
25162519return [Name ('DeviceRGB' ),Op .setcolorspace_nonstroke ]
25172520else :
2518- hatch_style = (hatch_color ,self ._fillcolor ,hatch )
2521+ hatch_style = (hatch_color ,self ._fillcolor ,hatch , hatch_linewidth )
25192522name = self .file .hatchPattern (hatch_style )
25202523return [Name ('Pattern' ),Op .setcolorspace_nonstroke ,
25212524name ,Op .setcolor_nonstroke ]
@@ -2580,8 +2583,8 @@ def clip_cmd(self, cliprect, clippath):
25802583 (('_dashes' ,),dash_cmd ),
25812584 (('_rgb' ,),rgb_cmd ),
25822585# must come after fillcolor and rgb
2583- (('_hatch' ,'_hatch_color' ),hatch_cmd ),
2584- )
2586+ (('_hatch' ,'_hatch_color' , '_hatch_linewidth' ),hatch_cmd ),
2587+ )
25852588
25862589def delta (self ,other ):
25872590"""
@@ -2609,11 +2612,11 @@ def delta(self, other):
26092612break
26102613
26112614# Need to update hatching if we also updated fillcolor
2612- if params == ( '_hatch' , '_hatch_color' ) and fill_performed :
2615+ if cmd . __name__ == 'hatch_cmd' and fill_performed :
26132616different = True
26142617
26152618if different :
2616- if params == ( '_fillcolor' ,) :
2619+ if cmd . __name__ == 'fillcolor_cmd' :
26172620fill_performed = True
26182621theirs = [getattr (other ,p )for p in params ]
26192622cmds .extend (cmd (self ,* theirs ))