Skip to content

Commit 003ea0b

Browse files
authored
Enables hatch alpha on SVG
Partially addresses matplotlib#16883 Adds `stroke-opacity` to hatch, but only if it's set to anything less than 1.
1 parent ef0f6e4 commit 003ea0b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/matplotlib/backends/backend_svg.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,16 +391,19 @@ def _write_hatches(self):
391391
x="0", y="0", width=str(HATCH_SIZE+1),
392392
height=str(HATCH_SIZE+1),
393393
fill=fill)
394-
writer.element(
395-
'path',
396-
d=path_data,
397-
style=generate_css({
394+
hatch_style = {
398395
'fill': rgb2hex(stroke),
399396
'stroke': rgb2hex(stroke),
400397
'stroke-width': str(mpl.rcParams['hatch.linewidth']),
401398
'stroke-linecap': 'butt',
402399
'stroke-linejoin': 'miter'
403-
})
400+
}
401+
if stroke[3] < 1.:
402+
hatch_style['stroke-opacity'] = str(stroke[3])
403+
writer.element(
404+
'path',
405+
d=path_data,
406+
style=generate_css(hatch_style)
404407
)
405408
writer.end('pattern')
406409
writer.end('defs')

0 commit comments

Comments
 (0)