Проблема Seaborn с кошачьим сюжетом

Я следил за кодом в новой версии seaborn 0.9.0, отображаемым на сайте, и при вводе следующего кода у меня возникла ошибка. Код взят снизу этой страницы https://seaborn.pydata.org/tutorial/categorical.html

import seaborn as sns
tips = sns.load_dataset("tips")
sns.catplot(x="day", y="total_bill", hue="smoker",
            col="time", aspect=.6,
            kind="swarm", data=tips);

Это результат выполнения приведенного выше кода. Я попытался создать новую среду, и все было обновлено. Я до сих пор не знаю, почему не работает.

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-21-c1ae50b18a54> in <module>
      3 sns.catplot(x="day", y="total_bill", hue="smoker",
      4             col="time", aspect=.6,
----> 5             kind="swarm", data=tips);
      6 get_ipython().run_line_magic('version_information', '')

~/anaconda3/envs/python3/lib/python3.7/site-packages/seaborn/categorical.py in catplot(x, y, hue, data, row, col, col_wrap, estimator, ci, n_boot, units, order, hue_order, row_order, col_order, kind, height, aspect, orient, color, palette, legend, legend_out, sharex, sharey, margin_titles, facet_kws, **kwargs)
   3753 
   3754     # Draw the plot onto the facets
-> 3755     g.map_dataframe(plot_func, x, y, hue, **plot_kws)
   3756 
   3757     # Special case axis labels for a count type plot

~/anaconda3/envs/python3/lib/python3.7/site-packages/seaborn/axisgrid.py in map_dataframe(self, func, *args, **kwargs)
    818 
    819             # Draw the plot
--> 820             self._facet_plot(func, ax, args, kwargs)
    821 
    822         # Finalize the annotations and layout

~/anaconda3/envs/python3/lib/python3.7/site-packages/seaborn/axisgrid.py in _facet_plot(self, func, ax, plot_args, plot_kwargs)
    836 
    837         # Draw the plot
--> 838         func(*plot_args, **plot_kwargs)
    839 
    840         # Sort out the supporting information

~/anaconda3/envs/python3/lib/python3.7/site-packages/seaborn/categorical.py in swarmplot(x, y, hue, data, order, hue_order, dodge, orient, color, palette, size, edgecolor, linewidth, ax, **kwargs)
   2989                        linewidth=linewidth))
   2990 
-> 2991     plotter.plot(ax, kwargs)
   2992     return ax
   2993 

~/anaconda3/envs/python3/lib/python3.7/site-packages/seaborn/categorical.py in plot(self, ax, kws)
   1444     def plot(self, ax, kws):
   1445         """Make the full plot."""
-> 1446         self.draw_swarmplot(ax, kws)
   1447         self.add_legend_data(ax)
   1448         self.annotate_axes(ax)

~/anaconda3/envs/python3/lib/python3.7/site-packages/seaborn/categorical.py in draw_swarmplot(self, ax, kws)
   1404                 kws.update(c=point_colors)
   1405                 if self.orient == "v":
-> 1406                     points = ax.scatter(cat_pos, swarm_data, s=s, **kws)
   1407                 else:
   1408                     points = ax.scatter(swarm_data, cat_pos, s=s, **kws)

~/anaconda3/envs/python3/lib/python3.7/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
   1803                         "the Matplotlib list!)" % (label_namer, func.__name__),
   1804                         RuntimeWarning, stacklevel=2)
-> 1805             return func(ax, *args, **kwargs)
   1806 
   1807         inner.__doc__ = _add_data_doc(inner.__doc__,

~/anaconda3/envs/python3/lib/python3.7/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, **kwargs)
   4193                 isinstance(c, str) or
   4194                 (isinstance(c, collections.Iterable) and
-> 4195                     isinstance(c[0], str))):
   4196             c_array = None
   4197         else:

IndexError: index 0 is out of bounds for axis 0 with size 0

person M_L_    schedule 20.11.2018    source источник


Ответы (1)


К сожалению, это ошибка в matplotlib 3.0.1. Об этом сообщалось здесь и исправлено pull / 12673.

Возможные варианты: установить matplotlib 3.0.0 или 3.0.2.

person ImportanceOfBeingErnest    schedule 20.11.2018