You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DataFrame.hist() does not get along with matplotlib.pyplot.tight_layout() #9351
When tight_layout() is called after DataFrame.hist() it raises AttributeError: 'NoneType' object has no attribute 'is_bbox if any of subplots is empty (number of charts with histograms is smaller than number os subplots).
Actually, just before the error is raised, subplots is a list of one AxesSubplot instance for which get_visible() returns False. ax.get_tightbbox() returns None for invisible axes and auto_adjust_subplotpars() pass this None to TransformedBbox(), which expects a real Bbox and raises the exception.
Looks like a matplotlib issue to me, or maybe pandas should not be creating that invisible Axes.
A quick workaround would be to add something like this:
This is now fixed downstream in matplotlib as #8255 by PR#8244. Once matplotlib 2.0.1 lands this issue will be fixed and can be closed (use mpl > 2.0.1). For the moment best to leave it open though.
@ResidentMario the regression test passed though, contrary to the bug fix that was needed, right? (IIRC you did another PR which added a slightly different test which failed though..?)
@jreback Wasn't sure what best practice is for telling users to use a version of a downstream library which may or may not be out yet (maybe pandas 0.20.0 will beat matplotlib 2.0.1 to release). But since the update note is already in place, sure this issue can be closed—but, you should remove the errant test first (see the PR above).
Activity
ericmjl commentedon May 19, 2015
Ditto here, I can't seem to figure out what's going on.
TomAugspurger commentedon May 19, 2015
Would either of you want to dig into what's causing the problem?
It seems that
in
matplotlib.tight_layout.auto_adjust_subplotparsreturns None when it's expected to return aBBox.goyodiaz commentedon Dec 15, 2015
Actually, just before the error is raised,
subplotsis a list of oneAxesSubplotinstance for whichget_visible()returnsFalse.ax.get_tightbbox()returnsNonefor invisible axes andauto_adjust_subplotpars()pass thisNonetoTransformedBbox(), which expects a realBboxand raises the exception.Looks like a matplotlib issue to me, or maybe pandas should not be creating that invisible
Axes.A quick workaround would be to add something like this:
But it might have side effects.
miraculixx commentedon Feb 25, 2016
+1
ResidentMario commentedon Feb 26, 2017
As of
matplotlib 2.0this now works as expected.jreback commentedon Feb 26, 2017
@ResidentMario can you add a test to confirm this behavior (that skips if mpl < 2.0)?
Add a unit test for pandas-dev#9351.
Add unit test for pandas-dev#9351
7 remaining items
ResidentMario commentedon Mar 7, 2017
This boils down to a
matplotlibbug. This is whatpandasis doing internally, which fails:Going about it a slightly different way, this works:
ResidentMario commentedon Mar 12, 2017
This is now fixed downstream in
matplotlibas #8255 by PR#8244. Oncematplotlib 2.0.1lands this issue will be fixed and can be closed (usempl > 2.0.1). For the moment best to leave it open though.jreback commentedon Mar 13, 2017
thanks @ResidentMario ok can update the release note at some point. any additional tests needed?
ResidentMario commentedon Mar 13, 2017
@jreback I would say no, the PR included a regression test for this in the
matplotlibtest suite.jreback commentedon Mar 13, 2017
@ResidentMario the regression test passed though, contrary to the bug fix that was needed, right? (IIRC you did another PR which added a slightly different test which failed though..?)
jreback commentedon Mar 13, 2017
this was corrected in 03dca96
any reason not to close this issue?
TST: remove errant test
ResidentMario commentedon Mar 13, 2017
@jreback Wasn't sure what best practice is for telling users to use a version of a downstream library which may or may not be out yet (maybe
pandas 0.20.0will beatmatplotlib 2.0.1to release). But since the update note is already in place, sure this issue can be closed—but, you should remove the errant test first (see the PR above).jorisvandenbossche commentedon Mar 13, 2017
Yeah, I saw the typo of 0.2 vs 2.0, and thought to directly make this 2.0.1, because that is more correct.
TST: fix errant tight_layout test (#15671)
TST: DataFrame.hist() does not get along with matplotlib.pyplot.tight…
TST: fix errant tight_layout test (pandas-dev#15671)
TST: fix errant tight_layout test (pandas-dev#15671)