-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Shadow applied to a simple patch does not show #9377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Apparently, you have to add the patch to an Axes instance before creating an instance of import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
fig, ax = plt.subplots()
rectangle = mpatches.Rectangle(xy=(1.0, 1.0), width=1.0, height=0.50)
ax.add_patch(rectangle)
ax.set_xlim([0, 3])
ax.set_ylim([0, 3])
shadow = mpatches.Shadow(rectangle, ox=0.20, oy=-0.10)
shadow.set_zorder(rectangle.get_zorder() - 1) # draw *shadow* below *rectangle*
ax.add_patch(shadow)
fig.savefig("shadow.png") |
@clintval I am not sure that anything is really wrong with |
The z-order issue should probably be correct by default. Calling I think the problem is that the |
I had to set the zorder directly in @afvincent's example. The Interestingly, calling import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
fig, ax = plt.subplots(1, 1, figsize=(5, 5))
rectangle = mpatches.Rectangle(
xy=(0.25, 0.25),
width=1/2,
height=1/2)
shadow = mpatches.Shadow(
rectangle,
ox=0.25,
oy=0.25)
ax.add_patch(rectangle)
ax.add_patch(shadow)
shadow._update() What would you all suggest as an enhancement? Shadow transformMinimally, I would like to contribute a message to the docstring of Shadow zorderThe default shadow behavior is to have the same zorder as the selected patch. It would be nice to have the shadow set a smaller zorder by default. Having the patches in the same plane is confusing. Thanks for the time! this is my first time reaching out the |
@clintval I think that both of those are great ideas! |
#9426 should fix the "incorrect transform" part. A zorder fix would still be worthwhile, before anyone writes |
Bug report
Bug summary
Adding a shadow to a patch as described in the documentation does nothing. From the documentation it appears as if
matplotlib.patches.Shadow
accepts apatch
object. I am also not clear on the units of the requiredox
andoy
properties.Code for reproduction
Actual outcome
Expected outcome
A shadow of the blue rectangle patch nearby.
Matplotlib version
I installed
matplotlib
via the Arch package repositories atsudo pacman -S python-matplotlib
.Edit: added a missing import to make the example self-sufficient. (afvincent)
The text was updated successfully, but these errors were encountered: