Seaborn的FactorPlot抛出TypeError

0 投票
1 回答
985 浏览
提问于 2025-04-18 17:02

sns.FactorPlot在尝试设置标题时给我抛出了一个类型错误。这在一个示例数据框上发生,但更令人担忧的是,这个问题在文档中的示例上也出现了。

所以

import seaborn as sns
exercise = sns.load_dataset('exercise')
sns.factorplot("kind", "pulse", "diet", exercise, kind="point")

返回了一个很长的错误追踪信息。这里是它的结尾部分:

*/lib/python2.7/site-packages/seaborn/linearmodels.pyc in plot(self, ax)
    275             if hasattr(self.hue, "name"):
    276                 leg.set_title(self.hue.name,
--> 277                               prop={"size": mpl.rcParams["axes.labelsize"]})
    278         ax.xaxis.grid(False)
    279         ax.set_xticks(self.positions)

TypeError: set_title() got an unexpected keyword argument 'prop'

当我在启用了pylab inline的iPython Notebook中运行这个时,图表在错误追踪信息下面正常显示。但我不明白为什么会出现这个错误,尤其是文档中的示例也会这样。

1 个回答

2

这个错误出现在seaborn 0.3.1版本和matplotlib 1.2以下的版本中。不过,你可以通过更新matplotlib或者seaborn来解决这个问题(现在的做法是从github上安装seaborn的开发版本)。

撰写回答