Skip to content

df.plot(ax=ax) AttributeError: 'Axes' object has no attribute 'is_first_col' #11520

Closed
@dragoljub

Description

@dragoljub

When attempting to use the Pandas 0.17.0 plot method to target plotting on an external axes: AttributeError: 'Axes' object has no attribute 'is_first_col'.

Pandas: 0.17.0
Numpy: 1.9.2
Matplotlib: 1.5.0

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

df = pd.DataFrame({'A' : ['foo', 'bar', 'foo', 'bar',
                          'foo', 'bar', 'foo', 'foo'],
                    'B' : ['one', 'one', 'two', 'three',
                          'two', 'two', 'one', 'three'],
                    'C' : np.random.randn(8),
                    'D' : np.random.randn(8)})

fig = plt.figure()
ax = fig.add_axes((0,0,1,1))

df.plot(kind='scatter', ax=ax, x='C', y='D', c=df.C, s=100, linewidth=0, colormap='hsv')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-21-b38f872a3fc3> in <module>()
----> 1 df.plot(kind='scatter', ax=ax, x='C', y='D', c=df.C, s=100, linewidth=0)

D:\Python27\lib\site-packages\pandas\tools\plotting.pyc in __call__(self, x, y, kind, ax, subplots, sharex, sharey, layout, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, secondary_y, sort_columns, **kwds)
   3665                           fontsize=fontsize, colormap=colormap, table=table,
   3666                           yerr=yerr, xerr=xerr, secondary_y=secondary_y,
-> 3667                           sort_columns=sort_columns, **kwds)
   3668     __call__.__doc__ = plot_frame.__doc__
   3669 

D:\Python27\lib\site-packages\pandas\tools\plotting.pyc in plot_frame(data, x, y, kind, ax, subplots, sharex, sharey, layout, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, secondary_y, sort_columns, **kwds)
   2550                  yerr=yerr, xerr=xerr,
   2551                  secondary_y=secondary_y, sort_columns=sort_columns,
-> 2552                  **kwds)
   2553 
   2554 

D:\Python27\lib\site-packages\pandas\tools\plotting.pyc in _plot(data, x, y, subplots, ax, kind, **kwds)
   2378         plot_obj = klass(data, subplots=subplots, ax=ax, kind=kind, **kwds)
   2379 
-> 2380     plot_obj.generate()
   2381     plot_obj.draw()
   2382     return plot_obj.result

D:\Python27\lib\site-packages\pandas\tools\plotting.pyc in generate(self)
    990             self._post_plot_logic_common(ax, self.data)
    991             self._post_plot_logic(ax, self.data)
--> 992         self._adorn_subplots()
    993 
    994     def _args_adjust(self):

D:\Python27\lib\site-packages\pandas\tools\plotting.pyc in _adorn_subplots(self)
   1141                                 naxes=nrows * ncols, nrows=nrows,
   1142                                 ncols=ncols, sharex=self.sharex,
-> 1143                                 sharey=self.sharey)
   1144 
   1145         for ax in self.axes:

D:\Python27\lib\site-packages\pandas\tools\plotting.pyc in _handle_shared_axes(axarr, nplots, naxes, nrows, ncols, sharex, sharey)
   3403                 # as we only have labels in teh first column and we always have a subplot there,
   3404                 # we can skip the layout test
-> 3405                 if ax.is_first_col():
   3406                     continue
   3407                 if sharey or len(ax.get_shared_y_axes().get_siblings(ax)) > 1:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions