jvns / pandas-cookbook

Recipes for using Python's pandas library
6.65k stars 2.32k forks source link

Error when plotting for Chapter 1 #40

Open cniedotus opened 8 years ago

cniedotus commented 8 years ago

Similar errors exist for plots in other chapters too. I found the solution to be here:

http://stackoverflow.com/questions/33995707/attributeerror-unknown-property-color-cycle


AttributeError Traceback (most recent call last)

in () ----> 1 fixed_df['Berri 1'].plot() /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/tools/plotting.pyc 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) 3495 colormap=colormap, table=table, yerr=yerr, 3496 xerr=xerr, label=label, secondary_y=secondary_y, -> 3497 *_kwds) 3498 **call**.**doc** = plot_series.**doc** 3499 /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/tools/plotting.pyc 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) 2585 yerr=yerr, xerr=xerr, 2586 label=label, secondary_y=secondary_y, -> 2587 *_kwds) 2588 2589 /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/tools/plotting.pyc in _plot(data, x, y, subplots, ax, kind, *_kwds) 2382 plot_obj = klass(data, subplots=subplots, ax=ax, kind=kind, *_kwds) 2383 -> 2384 plot_obj.generate() 2385 plot_obj.draw() 2386 return plot_obj.result /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/tools/plotting.pyc in generate(self) 985 self._compute_plot_data() 986 self._setup_subplots() --> 987 self._make_plot() 988 self._add_table() 989 self._make_legend() /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/tools/plotting.pyc in _make_plot(self) 1662 stacking_id=stacking_id, 1663 is_errorbar=is_errorbar, -> 1664 **kwds) 1665 self._add_legend_handle(newlines[0], label, index=i) 1666 /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/tools/plotting.pyc in _ts_plot(cls, ax, x, data, style, *_kwds) 1699 ax._plot_data.append((data, cls._kind, kwds)) 1700 -> 1701 lines = cls._plot(ax, data.index, data.values, style=style, *_kwds) 1702 # set date formatter, locators and rescale limits 1703 format_dateaxis(ax, ax.freq) /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/tools/plotting.pyc in _plot(cls, ax, x, y, style, column_num, stacking_id, *_kwds) 1676 cls._initialize_stacker(ax, stacking_id, len(y)) 1677 y_values = cls._get_stacked_values(ax, stacking_id, y, kwds['label']) -> 1678 lines = MPLPlot._plot(ax, x, y_values, style=style, *_kwds) 1679 cls._update_stacker(ax, stacking_id, y) 1680 return lines /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/tools/plotting.pyc in _plot(cls, ax, x, y, style, is_errorbar, *_kwds) 1298 else: 1299 args = (x, y) -> 1300 return ax.plot(_args, **kwds) 1301 1302 def _get_index_name(self): /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/**init**.pyc in inner(ax, _args, *_kwargs) 1810 warnings.warn(msg % (label_namer, func.**name**), 1811 RuntimeWarning, stacklevel=2) -> 1812 return func(ax, _args, *_kwargs) 1813 pre_doc = inner.**doc** 1814 if pre_doc is None: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in plot(self, _args, *_kwargs) 1422 kwargs['color'] = c 1423 -> 1424 for line in self._get_lines(_args, *_kwargs): 1425 self.add_line(line) 1426 lines.append(line) /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in _grab_next_args(self, _args, *_kwargs) 384 return 385 if len(remaining) <= 3: --> 386 for seg in self._plot_args(remaining, kwargs): 387 yield seg 388 return /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in _plot_args(self, tup, kwargs) 372 ncx, ncy = x.shape[1], y.shape[1] 373 for j in xrange(max(ncx, ncy)): --> 374 seg = func(x[:, j % ncx], y[:, j % ncy], kw, kwargs) 375 ret.append(seg) 376 return ret /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in _makeline(self, x, y, kw, kwargs) 278 default_dict = self._getdefaults(None, kw, kwargs) 279 self._setdefaults(default_dict, kw, kwargs) --> 280 seg = mlines.Line2D(x, y, *_kw) 281 self.set_lineprops(seg, *_kwargs) 282 return seg /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/lines.pyc in **init**(self, xdata, ydata, linewidth, linestyle, color, marker, markersize, markeredgewidth, markeredgecolor, markerfacecolor, markerfacecoloralt, fillstyle, antialiased, dash_capstyle, solid_capstyle, dash_joinstyle, solid_joinstyle, pickradius, drawstyle, markevery, **kwargs) 365 # update kwargs before updating data to give the caller a 366 # chance to init axes (and hence unit support) --> 367 self.update(kwargs) 368 self.pickradius = pickradius 369 self.ind_offset = 0 /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/artist.pyc in update(self, props) 854 func = getattr(self, 'set_' + k, None) 855 if func is None or not six.callable(func): --> 856 raise AttributeError('Unknown property %s' % k) 857 func(v) 858 changed = True AttributeError: Unknown property color_cycle