From ab3478c3c8b39d18f0be0ba1d170168447ad4391 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Tue, 16 Jun 2020 23:38:21 -0400 Subject: [PATCH 1/2] Fix default artist properties for Shadow. Starting with #16098, extra keyword arguments are now processed, but that means that default colours and alpha are not set. Instead, those properties should only be overridden if specified. --- lib/matplotlib/patches.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index 490148ed0794..5811cba39ada 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -645,7 +645,14 @@ def __init__(self, patch, ox, oy, props=None, **kwargs): self.patch = patch # Note: when removing props, we can directly pass kwargs to _update() # and remove self._props - self._props = {**(props if props is not None else {}), **kwargs} + if props is None: + color = .3 * np.asarray(colors.to_rgb(self.patch.get_facecolor())) + props = { + 'facecolor': color, + 'edgecolor': color, + 'alpha': 0.5, + } + self._props = {**props, **kwargs} self._ox, self._oy = ox, oy self._shadow_transform = transforms.Affine2D() self._update() @@ -658,13 +665,7 @@ def _update(self): # Place the shadow patch directly behind the inherited patch. self.set_zorder(np.nextafter(self.patch.zorder, -np.inf)) - if self._props: - self.update(self._props) - else: - color = .3 * np.asarray(colors.to_rgb(self.patch.get_facecolor())) - self.set_facecolor(color) - self.set_edgecolor(color) - self.set_alpha(0.5) + self.update(self._props) def _update_transform(self, renderer): ox = renderer.points_to_pixels(self._ox) From 3497b07ca171b97204b49928cda2778851bb0995 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Tue, 16 Jun 2020 23:41:03 -0400 Subject: [PATCH 2/2] Simplify setup of pie() shadows. A `Shadow` already sets zorder immediately below its parent patch, so that's no longer necessary. --- lib/matplotlib/axes/_axes.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 81f8aa4ee4d4..076e719df208 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -3076,8 +3076,7 @@ def get_next_color(): if shadow: # Make sure to add a shadow after the call to add_patch so the # figure and transform props will be set. - shad = mpatches.Shadow(w, -0.02, -0.02) - shad.set(zorder=0.9 * w.get_zorder(), label='_nolegend_') + shad = mpatches.Shadow(w, -0.02, -0.02, label='_nolegend_') self.add_patch(shad) if labeldistance is not None: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy