Plotting fails when using subplot grid + manual axis · Issue #11556 · pandas-dev/pandas (original) (raw)

The following code raises an error (tested on pandas 0.17.0, matplotlib 1.4.3, and Python 3.4.2)

>>> fig, ax = plt.subplots()
>>> fig.add_axes([0.2, 0.2, 0.2, 0.2])
>>> pd.Series(np.random.rand(100)).plot(ax=ax)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-13-80531efe48c4> in <module>()
      8 fig, ax = plt.subplots()
      9 inset = fig.add_axes([0.2, 0.2, 0.2, 0.2])
---> 10 data.plot(ax=ax)

/Users/jakevdp/anaconda/envs/python3.4/lib/python3.4/site-packages/pandas/tools/plotting.py in __call__(self, kind, ax, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, label, secondary_y, **kwds)
   3491                            colormap=colormap, table=table, yerr=yerr,
   3492                            xerr=xerr, label=label, secondary_y=secondary_y,
-> 3493                            **kwds)
   3494     __call__.__doc__ = plot_series.__doc__
   3495 

/Users/jakevdp/anaconda/envs/python3.4/lib/python3.4/site-packages/pandas/tools/plotting.py in plot_series(data, kind, ax, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, label, secondary_y, **kwds)
   2581                  yerr=yerr, xerr=xerr,
   2582                  label=label, secondary_y=secondary_y,
-> 2583                  **kwds)
   2584 
   2585 

/Users/jakevdp/anaconda/envs/python3.4/lib/python3.4/site-packages/pandas/tools/plotting.py 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

/Users/jakevdp/anaconda/envs/python3.4/lib/python3.4/site-packages/pandas/tools/plotting.py 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):

/Users/jakevdp/anaconda/envs/python3.4/lib/python3.4/site-packages/pandas/tools/plotting.py 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:

/Users/jakevdp/anaconda/envs/python3.4/lib/python3.4/site-packages/pandas/tools/plotting.py in _handle_shared_axes(axarr, nplots, naxes, nrows, ncols, sharex, sharey)
   3378                 layout = np.zeros((nrows+1,ncols+1), dtype=np.bool)
   3379                 for ax in axarr:
-> 3380                     layout[ax.rowNum, ax.colNum] = ax.get_visible()
   3381 
   3382                 for ax in axarr:

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