Skip to content

Share and unshare axes after creation. #9923

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

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix test related to sharing
  • Loading branch information
lkjell committed Jun 24, 2018
commit df83b529c5ea256ea13a997d54ee3058b71a43f6
5 changes: 2 additions & 3 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1289,8 +1289,7 @@ def set_aspect(self, aspect, adjustable=None, anchor=None, share=False):
if not (isinstance(aspect, str) and aspect in ('equal', 'auto')):
aspect = float(aspect) # raise ValueError if necessary
if share:
axes = set(self._shared_x_axes.get_siblings(self)
+ self._shared_y_axes.get_siblings(self))
axes = set(self._shared_x_axes | self._shared_y_axes)
else:
axes = [self]
for ax in axes:
Expand Down Expand Up @@ -4325,7 +4324,7 @@ def _share_axes(self, axes, shared_axes):

for ax in shared:
setattr(ax, shared_axes, shared)
ax._adjustable = 'datalim'
# ax._adjustable = 'datalim'

def share_x_axes(self, axes):
"""
Expand Down
4 changes: 3 additions & 1 deletion lib/matplotlib/tests/test_subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ def check_shared(axs, x_shared, y_shared):
enumerate(zip("xy", [x_shared, y_shared]))):
if i2 <= i1:
continue
share = getattr(ax1, "_shared_{}_axes".format(name))
share = ax2 in share
assert \
(getattr(axs[0], "_shared_{}_axes".format(name)).joined(ax1, ax2)
(share
== shared[i1, i2]), \
"axes %i and %i incorrectly %ssharing %s axis" % (
i1, i2, "not " if shared[i1, i2] else "", name)
Expand Down