Skip to content
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

fix GridSpec.update to update axes position only for axes assocaited with the gridspec instance. #472

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 11 additions & 8 deletions lib/matplotlib/gridspec.py
Expand Up @@ -233,14 +233,17 @@ def update(self, **kwargs):
if not isinstance(ax, SubplotBase):
# Check if sharing a subplots axis
if ax._sharex is not None and isinstance(ax._sharex, SubplotBase):
ax._sharex.update_params()
ax.set_position(ax._sharex.figbox)
if ax._sharex.get_subplotspec().get_gridspec() == self:
ax._sharex.update_params()
ax.set_position(ax._sharex.figbox)
elif ax._sharey is not None and isinstance(ax._sharey,SubplotBase):
ax._sharey.update_params()
ax.set_position(ax._sharey.figbox)
if ax._sharey.get_subplotspec().get_gridspec() == self:
ax._sharey.update_params()
ax.set_position(ax._sharey.figbox)
else:
ax.update_params()
ax.set_position(ax.figbox)
if ax.get_subplotspec().get_gridspec() == self:
ax.update_params()
ax.set_position(ax.figbox)



Expand Down Expand Up @@ -287,7 +290,7 @@ def tight_layout(self, fig, renderer=None, pad=1.2, h_pad=None, w_pad=None, rect
subplot_list = []
num1num2_list = []
subplot_dict = {}

for ax in fig.axes:
locator = ax.get_axes_locator()
if hasattr(locator, "get_subplotspec"):
Expand Down Expand Up @@ -340,7 +343,7 @@ def tight_layout(self, fig, renderer=None, pad=1.2, h_pad=None, w_pad=None, rect
pad=pad, h_pad=h_pad, w_pad=w_pad,
rect=(left, bottom, right, top))


self.update(**kwargs)


Expand Down