FFFF Fix barplot color if none and alpha is set · matplotlib/matplotlib@dd52123 · GitHub
[go: up one dir, main page]

Skip to content

Commit dd52123

Browse files
committed
Fix barplot color if none and alpha is set
1 parent ff059c0 commit dd52123

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,14 +1999,14 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
19991999
linewidth = itertools.cycle(np.atleast_1d(linewidth))
20002000
color = itertools.chain(itertools.cycle(mcolors.to_rgba_array(color)),
20012001
# Fallback if color == "none".
2002-
itertools.repeat([0, 0, 0, 0]))
2002+
itertools.repeat('none'))
20032003
if edgecolor is None:
20042004
edgecolor = itertools.repeat(None)
20052005
else:
20062006
edgecolor = itertools.chain(
20072007
itertools.cycle(mcolors.to_rgba_array(edgecolor)),
20082008
# Fallback if edgecolor == "none".
2009-
itertools.repeat([0, 0, 0, 0]))
2009+
itertools.repeat('none'))
20102010

20112011
# We will now resolve the alignment and really have
20122012
# left, bottom, width, height vectors

lib/matplotlib/tests/test_axes.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,6 +1456,22 @@ def test_bar_tick_label_multiple_old_alignment():
14561456
align='center')
14571457

14581458

1459+
def test_bar_color_none_alpha():
1460+
ax = plt.gca()
1461+
rects = ax.bar([1, 2], [2, 4], alpha=0.3, color='none', edgecolor='r')
1462+
for rect in rects:
1463+
assert rect.get_facecolor() == (0, 0, 0, 0)
1464+
assert rect.get_edgecolor() == (1, 0, 0, 0.3)
1465+
1466+
1467+
def test_bar_edgecolor_none_alpha():
1468+
ax = plt.gca()
1469+
rects = ax.bar([1, 2], [2, 4], alpha=0.3, color='r', edgecolor='none')
1470+
for rect in rects:
1471+
assert rect.get_facecolor() == (1, 0, 0, 0.3)
1472+
assert rect.get_edgecolor() == (0, 0, 0, 0)
1473+
1474+
14591475
@image_comparison(baseline_images=['barh_tick_label'],
14601476
extensions=['png'])
14611477
def test_barh_tick_label():

0 commit comments

Comments
 (0)
0