Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Restore axes sharedness when unpickling. #11544

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

Merged
merged 1 commit into from
Jul 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions 20 lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,17 +542,25 @@ def __getstate__(self):
# The renderer should be re-created by the figure, and then cached at
# that point.
state = super().__getstate__()
state['_cachedRenderer'] = None
state.pop('_layoutbox')
state.pop('_poslayoutbox')

for key in ['_cachedRenderer', '_layoutbox', '_poslayoutbox']:
state[key] = None
# Prune the sharing & twinning info to only contain the current group.
for grouper_name in [
'_shared_x_axes', '_shared_y_axes', '_twinned_axes']:
grouper = getattr(self, grouper_name)
state[grouper_name] = (grouper.get_siblings(self)
if self in grouper else None)
return state

def __setstate__(self, state):
# Merge the grouping info back into the global groupers.
for grouper_name in [
'_shared_x_axes', '_shared_y_axes', '_twinned_axes']:
siblings = state.pop(grouper_name)
if siblings:
getattr(self, grouper_name).join(*siblings)
self.__dict__ = state
self._stale = True
self._layoutbox = None
self._poslayoutbox = None

def get_window_extent(self, *args, **kwargs):
"""
Expand Down
7 changes: 7 additions & 0 deletions 7 lib/matplotlib/tests/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,10 @@ def test_rrulewrapper():
except RecursionError:
print('rrulewrapper pickling test failed')
raise


def test_shared():
fig, axs = plt.subplots(2, sharex=True)
fig = pickle.loads(pickle.dumps(fig))
fig.axes[0].set_xlim(10, 20)
assert fig.axes[1].get_xlim() == (10, 20)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.