8000 Fix default colouring of Shadows by QuLogic · Pull Request #17656 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don‘t we need zorder?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shadow sets a default zorder (immediately below the parent patch) that's better than this manually calculated one.

self.add_patch(shad)

if labeldistance is not None:
Expand Down
17 changes: 9 additions & 8 deletions lib/matplotlib/patches.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
0