3

需要帮忙。我正在从事一项需要进行探索性数据分析的任务。

我已经安装了seaborn。在用下面的代码行绘制图表时

chart1 = sns.catplot(x = "JUNCTIONTYPE", data = df3, kind = "count",  col= "SEVERITYDESC")
chart1.set_xticklabels(rotation=35, horizontalalignment='right')

我收到以下错误。


ValueError                                Traceback (most recent call last)
<ipython-input-30-d7f0b1b2a27f> in <module>
----> 1 chart1 = sns.catplot(x = "JUNCTIONTYPE", data = df3, kind = "count",  col= "SEVERITYDESC")
      2 chart1.set_xticklabels(rotation=35, horizontalalignment='right')

~/conda/envs/python/lib/python3.6/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)
   3722     # so we need to define ``palette`` to get default behavior for the
   3723     # categorical functions
-> 3724     p.establish_colors(color, palette, 1)
   3725     if kind != "point" or hue is not None:
   3726         palette = p.colors

~/conda/envs/python/lib/python3.6/site-packages/seaborn/categorical.py in establish_colors(self, color, palette, saturation)
    313         # Determine the gray color to use for the lines framing the plot
    314         light_vals = [colorsys.rgb_to_hls(*c)[1] for c in rgb_colors]
--> 315         lum = min(light_vals) * .6
    316         gray = mpl.colors.rgb2hex((lum, lum, lum))
    317 

ValueError: min() arg is an empty sequence

下面的代码也有类似的错误。不知道我错过了什么。请帮忙。

chart = sns.catplot(x = "COLLISIONTYPE", data = df3, kind = "count",  col= "SEVERITYDESC")
chart.set_xticklabels(rotation=65, horizontalalignment='right')
4

1 回答 1

0

这似乎是 seaborn v 0.11.0 上的一个错误,我通过将其降级到 v 0.10.1 解决了它

如果您使用的是 conda:

conda remove seaborn
conda install seaborn==0.10.1

如果你宁愿点:

pip uninstall seaborn
pip install seaborn==0.10.1
于 2020-12-15T23:46:02.147 回答