Skip to content

Pandas stopped working with matplotlib inset-axis #10407

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
floriangeigl opened this issue Jun 22, 2015 · 6 comments
Closed

Pandas stopped working with matplotlib inset-axis #10407

floriangeigl opened this issue Jun 22, 2015 · 6 comments
Labels
Milestone

Comments

@floriangeigl
Copy link

Hy,

in older versions pandas was able to plot onto inset-axis of matplotlib. In new versions this support seems to be broken. I was able to execute the following code without any exceptions using an old pandas version. However, the current pandas version (0.16.2) throws an exception. Since the last update of matplotlib is a while back, I think the bug is caused by a recent pandas update. (As far as i remember, I was able to plot onto inset-axis using pandas 0.16.0.)

import matplotlib.pylab as plt
import pandas as pd
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes

df = pd.DataFrame(range(10))
ax = df.plot() # OK
axins = zoomed_inset_axes(ax, 2)
df.plot(ax=axins) # Throws exception

The thrown exception:

/usr/local/lib/python2.7/dist-packages/pandas/tools/plotting.pyc in _handle_shared_axes(axarr, nplots, naxes, nrows, ncols, sharex, sharey)
   3324         layout = np.zeros((nrows+1,ncols+1), dtype=np.bool)
   3325         for ax in axarr:
-> 3326             layout[ax.rowNum, ax.colNum] = ax.get_visible()
   3327 
   3328         if sharex and nrows > 1:

AttributeError: 'Axes' object has no attribute 'rowNum'

Output of pd.show_version():

INSTALLED VERSIONS

commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-53-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.16.2
nose: 1.3.7
Cython: None
numpy: 1.9.2
scipy: 0.15.1
statsmodels: 0.6.1
IPython: 3.2.0
sphinx: 1.2.2
patsy: 0.3.0
dateutil: 2.4.2
pytz: 2015.4
bottleneck: None
tables: 3.2.0
numexpr: 2.4.3
matplotlib: 1.4.3
openpyxl: 2.0.5
xlrd: 0.9.3
xlwt: 0.7.5
xlsxwriter: None
lxml: 3.3.3
bs4: 4.3.2
html5lib: 0.99999
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: 0.6.2.None
psycopg2: None

@TomAugspurger TomAugspurger added this to the Next Major Release milestone Jun 22, 2015
@TomAugspurger
Copy link
Contributor

Looks like it was 015fc62

I've never used matplotlib's inset before. Do you know how matpltolib handles similar issues, since apparently an inset doesn't have all the properties of a full axes?

@floriangeigl
Copy link
Author

I also used matplotlib insets for the first time and I never read pandas nor matplotlib source code, so I might be the wrong person to help fixing this bug.

Nevertheless, I googled about that yesterday and the only page I found which may be helpful is: http://matplotlib.org/mpl_toolkits/axes_grid/users/overview.html

Dirty hacks I tried:
I tried to manually add the missing properties (rowNum, colNum) to the axins object, but I did not succeed. Another idea was to convert the axins object into a default axis object of matplotlib, but to do so (if it is even possible) I would need more matplotlib experience.

@fnielsen
Copy link

fnielsen commented Jul 9, 2015

I did not manage to find a workaround other than downgrading:

sudo -H pip install pandas==0.15.2

@jorisvandenbossche jorisvandenbossche modified the milestones: 0.17.1, Next Major Release Nov 15, 2015
@jorisvandenbossche
Copy link
Member

This is now fixed by #11561

@fnielsen
Copy link

I can confirm that the problem I had is no longer present with PyPI 0.17.1 version. Thanks.

@jorisvandenbossche
Copy link
Member

@fnielsen Thanks for confirming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants