10000 Merge pull request #2415 from kshramt/kshramt/fix_fill_opacity · matplotlib/matplotlib@6a5aa01 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a5aa01

Browse files
committed
Merge pull request #2415 from kshramt/kshramt/fix_fill_opacity
Bug: alpha parameter was ignored when fill color is #000000
2 parents 9804c5d + 78ae9d7 commit 6a5aa01

File tree

3 files changed

+298
-2
lines changed

3 files changed

+298
-2
lines changed

lib/matplotlib/backends/backend_svg.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,9 @@ def _get_style_dict(self, gc, rgbFace):
406406
else:
407407
if rgbFace is None:
408408
attrib['fill'] = 'none'
409-
elif tuple(rgbFace[:3]) != (0, 0, 0):
410-
attrib['fill'] = rgb2hex(rgbFace)
409+
else:
410+
if tuple(rgbFace[:3]) != (0, 0, 0):
411+
attrib['fill'] = rgb2hex(rgbFace)
411412
if len(rgbFace) == 4 and rgbFace[3] != 1.0 and not forced_alpha:
412413
attrib['fill-opacity'] = str(rgbFace[3])
413414

Lines changed: 287 additions & 0 deletions
Loading

lib/matplotlib/tests/test_backend_svg.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ def test_visibility():
3636
parser.Parse(buf) # this will raise ExpatError if the svg is invalid
3737

3838

39+
@image_comparison(baseline_images=['fill_black_with_alpha'], remove_text=True,
40+
extensions=['svg'])
41+
def test_fill_black_with_alpha():
42+
fig = plt.figure()
43+
ax = fig.add_subplot(1, 1, 1)
44+
ax.scatter(x=[0, 0.1, 1], y=[0, 0, 0], c='k', alpha=0.1, s=10000)
45+
46+
3947
@image_comparison(baseline_images=['noscale'], remove_text=True)
4048
def test_noscale():
4149
X, Y = np.meshgrid(np.arange(-5, 5, 1), np.arange(-5, 5, 1))

0 commit comments

Comments
 (0)
0