Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Axes creation seems to reuse an old one instead of creating a new one #9024
It appears that when plt.axes() is called, if the parameters are identical to a previous call, that old axes is reused instead of creating a new one. I don't know if this is by design or not but it makes the behavior very unexpected.
Code for reproduction
%matplotlib notebook import matplotlib.pyplot as plt from matplotlib.widgets import Button from mpl_toolkits.axes_grid1 import inset_locator fig = plt.figure() ax = fig.add_subplot(111) a1=plt.axes([0,0,1,1], facecolor='yellow') pos1=inset_locator.InsetPosition(parent=ax,lbwh=[.5,.5,.04,.04]) a1.set_axes_locator(locator=pos1) b1=Button(a1,'1') a2=plt.axes([0,0,1,1], facecolor='yellow') # the parameters above are identical to those of a1, resulting in this behaving # as if one says a2=a1 pos2=inset_locator.InsetPosition(parent=ax,lbwh=[.6,.5,.04,.04]) a2.set_axes_locator(locator=pos2) b2=Button(a2,'2') a3=plt.axes([0,0,1,1], facecolor='orange') # the parameters above are different from previous axes() calls and therefore a new # axes is created pos3=inset_locator.InsetPosition(parent=ax,lbwh=[.7,.5,.04,.04]) a3.set_axes_locator(locator=pos3) b3=Button(a3,'3') # The use of buttons is to illustrate a use case. But it is not necessary; the behavior is the # same if one comments out the three Button() calls plt.show()
Two buttons appear, one with "1" and "2" on top of each other and the other with "3" in it.
Three buttons appear: "1", "2", and "3" horizontally.
How is it dealt with for twinning?…
On Aug 11, 2017 8:32 PM, "Eric Firing" ***@***.***> wrote: It's by design--an old design that none of us like. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#9024 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AARy-Aos5RoWgNrJxE7SNvK_l03XWh0-ks5sXPKpgaJpZM4O1Pzi> .
@efiring I more or less agree with this, though I suppose with my feature suggestion one of the open questions is "what will the user-facing API look like", so there might be some overlap there. That said, I think it's easy enough to say early on that whatever the user-facing API looks like, it doesn't need to include this sort of dubious behavior.
modified the milestones:
2.1 (next point release),
2.2 (next next feature release)
Aug 14, 2017
ah-ha! now that makes sense!…
On Wed, Aug 30, 2017 at 11:28 PM, Antony Lee ***@***.***> wrote: As a side note, in reply to #9024 (comment) <#9024 (comment)> (how is that dealt with when twinning) twinning happens to work because the second axes is created with the sharex=firstaxes additional kwarg, which thus does not trigger the bad behavior :) — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#9024 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AARy-HGgOT6a_FXv-xbezyBHDjid4pxgks5sdihIgaJpZM4O1Pzi> .