8000 Bug: alpha parameter was ignored when fill color is #000000 · matplotlib/matplotlib@78ae9d7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 78ae9d7

Browse files
author
kshramt
committed
Bug: alpha parameter was ignored when fill color is #000000
1 parent ddb4b45 commit 78ae9d7

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
@@ -405,8 +405,9 @@ def _get_style_dict(self, gc, rgbFace):
405405
else:
406406
if rgbFace is None:
407407
attrib['fill'] = 'none'
408-
elif tuple(rgbFace[:3]) != (0, 0, 0):
409-
attrib['fill'] = rgb2hex(rgbFace)
408+
else:
409+
if tuple(rgbFace[:3]) != (0, 0, 0):
410+
attrib['fill'] = rgb2hex(rgbFace)
410411
if len(rgbFace) == 4 and rgbFace[3] != 1.0 and not forced_alpha:
411412
attrib['fill-opacity'] = str(rgbFace[3])
412413

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
@@ -35,6 +35,14 @@ def test_visibility():
3535
parser.Parse(buf) # this will raise ExpatError if the svg is invalid
3636

3737

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

0 commit comments

Comments
 (0)
0