You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Shadow applied to a simple patch does not show #9377
Adding a shadow to a patch as described in the documentation does nothing. From the documentation it appears as if matplotlib.patches.Shadow accepts a patch object. I am also not clear on the units of the required ox and oy properties.
Apparently, you have to add the patch to an Axes instance before creating an instance of Shadow. Otherwise, something is undefined in the transforms pipeline (but this starts to be beyond my understanding...).
@clintval I am not sure that anything is really wrong with mpatches.Shadowexcept an unclear docstring, especially concerning the units of the offset and the underlying transform. While waiting for somebody, who really understands the “transform pipeline”, you may want to have a look at mtransforms.ScaledTranslation which seems to be a bit more explicit about its units.
The z-order issue should probably be correct by default.
Calling shadow._update will fix it.
I think the problem is that the Rectangle is not associated with the transfroms from the Axes until it is added but the Shadow copies the transform from the Rectangle and sets the flag that the tranform on the Shadow object has been set. This means that when you add the Shadow to the Axes later it does not set the transform to default (ax.transData) and the artist does not show up in the correct place.
I had to set the zorder directly in @afvincent's example. The Shadow patch inherited the same zorder as the rectangle and a call to shadow._update() did nothing to fix this.
Interestingly, calling shadow._update() in my initial example was another solution to binding the ax.transData to the patch.
Minimally, I would like to contribute a message to the docstring of matplotlib.patches.Shadow which would describe the limitations of using patch not yet bound to an ax.
Shadow zorder
The 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 matplotlib team!
#9426 should fix the "incorrect transform" part. A zorder fix would still be worthwhile, before anyone writes orig.zorder - 0.001, I'd suggest using np.nextafter(orig.zorder, -np.inf) :-)
Activity
afvincent commentedon Oct 12, 2017
Apparently, you have to add the patch to an Axes instance before creating an instance of
Shadow. Otherwise, something is undefined in the transforms pipeline (but this starts to be beyond my understanding...).produces

afvincent commentedon Oct 12, 2017
@clintval I am not sure that anything is really wrong with
mpatches.Shadowexcept an unclear docstring, especially concerning the units of the offset and the underlying transform. While waiting for somebody, who really understands the “transform pipeline”, you may want to have a look at mtransforms.ScaledTranslation which seems to be a bit more explicit about its units.tacaswell commentedon Oct 12, 2017
The z-order issue should probably be correct by default.
Calling
shadow._updatewill fix it.I think the problem is that the
Rectangleis not associated with the transfroms from theAxesuntil it is added but theShadowcopies the transform from theRectangleand sets the flag that the tranform on theShadowobject has been set. This means that when you add theShadowto theAxeslater it does not set the transform to default (ax.transData) and the artist does not show up in the correct place.clintval commentedon Oct 12, 2017
I had to set the zorder directly in @afvincent's example. The
Shadowpatch inherited the same zorder as the rectangle and a call toshadow._update()did nothing to fix this.Interestingly, calling
shadow._update()in my initial example was another solution to binding theax.transDatato the patch.What would you all suggest as an enhancement?
Shadow transform
Minimally, I would like to contribute a message to the docstring of
matplotlib.patches.Shadowwhich would describe the limitations of using patch not yet bound to an ax.Shadow zorder
The 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
matplotlibteam!tacaswell commentedon Oct 15, 2017
@clintval I think that both of those are great ideas!
anntzer commentedon Oct 16, 2017
#9426 should fix the "incorrect transform" part. A zorder fix would still be worthwhile, before anyone writes
orig.zorder - 0.001, I'd suggest usingnp.nextafter(orig.zorder, -np.inf):-)clintval commentedon Oct 16, 2017
I just submitted #9435. Along with #9426 this issue could be considered solved after merge.
I did not think editing the documentation was necessary as the two PRs address the odd behavior I was observing.
Thanks and do let me know if I missed anything!