Skip to content

Commit 325e698

Browse files
committed
Cairo backend: Fix alpha render of collections
Fixes #12773
1 parent 4dbbd22 commit 325e698

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/matplotlib/backends/backend_cairo.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,14 +303,14 @@ def _draw_paths():
303303
gc_vars, rgb_fc = reuse_key
304304
gc = copy.copy(gc0)
305305
# We actually need to call the setters to reset the internal state.
306-
vars(gc).update(gc_vars)
307306
for k, v in gc_vars.items():
308307
if k == "_linestyle": # Deprecated, no effect.
309308
continue
310309
try:
311310
getattr(gc, "set" + k)(v)
312311
except (AttributeError, TypeError) as e:
313312
pass
313+
vars(gc).update(gc_vars)
314314
gc.ctx.new_path()
315315
paths, transforms = zip(*grouped_draw)
316316
grouped_draw.clear()
@@ -327,7 +327,11 @@ def _draw_paths():
327327
.translate(xo, yo - self.height).scale(1, -1))
328328
# rgb_fc could be a ndarray, for which equality is elementwise.
329329
new_key = vars(gc0), tuple(rgb_fc) if rgb_fc is not None else None
330-
if new_key == reuse_key:
330+
# don't do grouped draw when doing alpha blending
331+
alpha_blending = gc0.get_forced_alpha() and gc0.get_alpha() < 1.0
332+
if not alpha_blending and rgb_fc is not None:
333+
alpha_blending = len(rgb_fc) == 4 and rgb_fc[-1] < 1.0
334+
if new_key == reuse_key and not alpha_blending:
331335
grouped_draw.append((path, transform))
332336
else:
333337
_draw_paths()

0 commit comments

Comments
 (0)