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
Bug in circle patch plotting when using the same patch for two different figures #3776
I think the issue is the transform used to position the Circle. Explicitly setting the transform of the Circle to ax.TransData seems to work as expected in the second example i.e. I can reproduce your issue but it works correctly with the following code.
I think that the issue is that the first time C is used it does not have a transform set so according to the docs it is set to transData of the axis. However the second time round it has a transformation set so it doesn't get a new one set but the transformation is set to the DataTrans of the first axis which is wrong in this context.
The docs of add_patch says the following:
Add a :class:`~matplotlib.patches.Patch` *p* to the list of
axes patches; the clipbox will be set to the Axes clipping
box. If the transform is not set, it will be set to
:attr:`transData`.
Can you reproduce the issue if you use a different circle patch for the second figure? If the above is a correct understanding that should change the behaviour.
Ah, this is not the bug I thought it was - this appears to be a bug related to re-using a patch in two different figures. If I use two different patches it all works fine. It has nothing to do with interpolation - I was trying to make a MWE for a different bug. But this still seems like something that should be fixed.
EDIT: just saw your comment - we converged on the same answer!
changed the title [-]Bug in circle patch plotting when not using nearest neighbor interpolation[/-][+]Bug in circle patch plotting when using the same patch for two different figures[/+]on Nov 9, 2014
Yes I think it would be good if add_patch replaced the transformation if the transformation belonging to the patch was for a different axis or alternatively raised an error. I have a hart time seeing that the present behaviour where you can add a patch with a transform with respect to one axis to another axis is useful.
If add_patch replaced the transform you would end up in the alternate problem where the second figure would be correct, but the first would not.
Artists have to associated with at most one axes. If we add any checks, it should probably be to raise an exception if ax.add_* is called on an artist which already has an axes. I think this should be on via turning Artist.axes into a property who's setter raises an exception if it the current value is not None or equal to the new value.
Activity
jenshnielsen commentedon Nov 9, 2014
I think the issue is the transform used to position the Circle. Explicitly setting the transform of the Circle to ax.TransData seems to work as expected in the second example i.e. I can reproduce your issue but it works correctly with the following code.
jenshnielsen commentedon Nov 9, 2014
Update.
I think that the issue is that the first time
Cis used it does not have a transform set so according to the docs it is set to transData of the axis. However the second time round it has a transformation set so it doesn't get a new one set but the transformation is set to the DataTrans of the first axis which is wrong in this context.The docs of add_patch says the following:
Can you reproduce the issue if you use a different circle patch for the second figure? If the above is a correct understanding that should change the behaviour.
astrofrog commentedon Nov 9, 2014
Ah, this is not the bug I thought it was - this appears to be a bug related to re-using a patch in two different figures. If I use two different patches it all works fine. It has nothing to do with interpolation - I was trying to make a MWE for a different bug. But this still seems like something that should be fixed.
EDIT: just saw your comment - we converged on the same answer!
[-]Bug in circle patch plotting when not using nearest neighbor interpolation[/-][+]Bug in circle patch plotting when using the same patch for two different figures[/+]jenshnielsen commentedon Nov 9, 2014
Yes I think it would be good if add_patch replaced the transformation if the transformation belonging to the patch was for a different axis or alternatively raised an error. I have a hart time seeing that the present behaviour where you can add a patch with a transform with respect to one axis to another axis is useful.
tacaswell commentedon Nov 9, 2014
If add_patch replaced the transform you would end up in the alternate problem where the second figure would be correct, but the first would not.
Artists have to associated with at most one axes. If we add any checks, it should probably be to raise an exception if
ax.add_*is called on an artist which already has an axes. I think this should be on via turningArtist.axesinto a property who's setter raises an exception if it the current value is not None or equal to the new value.jenshnielsen commentedon Dec 21, 2014
Closing since #3835 was merged.