Restore axes sharedness when unpickling.#11544
Conversation
Previously, pickling and unpickling shared axes would result in axes sharing a ticker instance (because that's how shared axes are set up), but without changes of one's xlims propagated to the other. The reason is that that sharedness information is stored in AxesBase._shared_x_axes, which does *not* get pickled together with the Axes instance: the latter only has a textual reference "I am an instance of AxesBase", so the Grouper information is lost. To keep the Grouper information valid, additionally pickle the current group of shared axes together with the Axes, and restore that information upon unpickling.
|
So, is it correct that now
Would be good enough for me. Do we have some place to document that you would always have to pickle the full set of shared axes together? |
To the best of my knowledge...
No, because there is a single grouper instance, unpickling B just readds its connected component to it (which is already there and doesn't change anything). Manually trying that (e.g. |
|
I am glad this ended up being much simpler than I expected. |
Alternative implementation of #10659, which addresses the issues raised in the comments.
Previously, pickling and unpickling shared axes would result in
axes sharing a ticker instance (because that's how shared axes
are set up), but without changes of one's xlims propagated to the
other. The reason is that that sharedness information is stored in
AxesBase._shared_x_axes, which does not get pickled together with the
Axes instance: the latter only has a textual reference "I am an instance
of AxesBase", so the Grouper information is lost.
this is the part of the implementation that changed
To keep the Grouper information valid, additionally pickle the current
group of shared axes together with the Axes, and restore that
information upon unpickling.
end of diff
PR Summary
PR Checklist