Skip to content

Conversation

leejjoon
Copy link
Contributor

tight_layout currently tries to make room for every subplot(-like axes) regardless of their visibility. With this PR, only visible axes are accounted.

@mdboom
Copy link
Member

mdboom commented May 15, 2013

👍, but maybe add a test?

@dmcdougall
Copy link
Member

+1 from me, too, with a test.

@pelson
Copy link
Member

pelson commented Aug 13, 2013

@leejjoon - this is good to go once we have a test. Any chance you would be able to do that, and then we can go ahead and merge.

Thanks,

@tacaswell
Copy link
Member

Should we go for this with out a test?

@tacaswell
Copy link
Member

And it will also need to be re-worked for the from __future__ ... changes and be six-ified.

@tacaswell tacaswell modified the milestones: v1.4.x, v1.4.0 Apr 4, 2014
@tacaswell tacaswell modified the milestones: 1.5.0, v1.4.x Feb 7, 2015
@has2k1 has2k1 mentioned this pull request May 25, 2015
@has2k1
Copy link
Contributor

has2k1 commented May 26, 2015

This does not work as expected.

Here is a minimal test

import matplotlib.pyplot as plt

x = y = [0, 1]
fig, axs = plt.subplots(2, 2)
axs = axs.flat

for ax in axs:
    ax.plot(x, y)

axs[1].set_visible(False)
axs[3].set_visible(False)

fig.patch.set_color('cyan')
plt.tight_layout()
plt.show()

Without this PR

Traceback (most recent call last):
  File "temp5.py", line 14, in <module>
    plt.tight_layout()
  File "/home/hassan/scm/python/matplotlib/lib/matplotlib/pyplot.py", line 1366, in tight_layout
    fig.tight_layout(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
  File "/home/hassan/scm/python/matplotlib/lib/matplotlib/figure.py", line 1717, in tight_layout
    rect=rect)
  File "/home/hassan/scm/python/matplotlib/lib/matplotlib/tight_layout.py", line 349, in get_tight_layout_figure
    pad=pad, h_pad=h_pad, w_pad=w_pad)
  File "/home/hassan/scm/python/matplotlib/lib/matplotlib/tight_layout.py", line 128, in auto_adjust_subplotpars
    fig.transFigure.inverted())
  File "/home/hassan/scm/python/matplotlib/lib/matplotlib/transforms.py", line 1069, in __init__
    if not bbox.is_bbox:
AttributeError: 'NoneType' object has no attribute 'is_bbox'

With this PR

lo

@tacaswell tacaswell modified the milestones: next point release, proposed next point release Jun 18, 2015
@tacaswell tacaswell closed this May 2, 2016
@tacaswell tacaswell reopened this May 2, 2016
@tacaswell tacaswell added status: needs review status: needs revision Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues and removed status: needs revision status: needs review labels May 2, 2016
@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Aug 29, 2017
@jklymak
Copy link
Member

jklymak commented Dec 12, 2017

I disagree w/ the PR, and given its languishing state suggest it be closed.

If the user makes room for 12 axes and only uses 2, I'd assume they had a plan for the other 10 slots. In #9082, I went to pretty great lengths to make sure that empty slots were maintained for the user.

@jklymak
Copy link
Member

jklymak commented Dec 13, 2017

Closing, given that this doesn't work as advertised, has languished, and I disagree w/ its goal. Feel free to reopen if you disagree!

@jklymak jklymak closed this Dec 13, 2017
@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues status: needs revision
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants