Skip to content

tight_layout not working with DataFrame.hist #13396

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
jluttine opened this issue Jun 8, 2016 · 1 comment
Closed

tight_layout not working with DataFrame.hist #13396

jluttine opened this issue Jun 8, 2016 · 1 comment

Comments

@jluttine
Copy link

jluttine commented Jun 8, 2016

Code Sample, a copy-pastable example if possible

First, relevant imports:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

This doesn't work:

pd.DataFrame(np.random.randn(100, 3)).hist()
plt.tight_layout()

It raises the following error:

AttributeError: 'NoneType' object has no attribute 'is_bbox'

I suppose this happens because it makes 2x2 plot grid but uses only three subplots. If I use all subplots, then it works:

pd.DataFrame(np.random.randn(100, 4)).hist()
plt.tight_layout()

Expected Output

Expected to get tight layout with 2x2 subplot grid.

It should be possible to make this work, because the following works with with matplotlib:

plt.figure()
plt.subplot(2, 2, 1)
plt.plot([1,2,3])
plt.subplot(2, 2, 2)
plt.plot([4,5,6])
plt.subplot(2, 2, 3)
plt.plot([7,8,9])
plt.tight_layout()

output of pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Linux
OS-release: 4.5.4-gnu-1
machine: x86_64
processor: 
byteorder: little
LC_ALL: None
LANG: en_DK.UTF-8

pandas: 0.18.1
nose: 1.3.7
pip: 8.1.1
setuptools: 20.2.1
Cython: 0.24
numpy: 1.11.0
scipy: 0.17.1
statsmodels: None
xarray: None
IPython: 4.2.0
sphinx: 1.4.2
patsy: None
dateutil: 2.5.3
pytz: 2016.4
blosc: None
bottleneck: None
tables: None
numexpr: 2.5.2
matplotlib: 1.5.1
openpyxl: None
xlrd: 0.9.4
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.4.1
html5lib: None
httplib2: 0.9.2
apiclient: 1.5.0
sqlalchemy: 1.0.13
pymysql: None
psycopg2: 2.6.1 (dt dec pq3 ext lo64)
jinja2: 2.8
boto: None
pandas_datareader: None
@jluttine
Copy link
Author

jluttine commented Jun 8, 2016

Ooohps, duplicate of #9351

@jluttine jluttine closed this as completed Jun 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant