Seaborn 箱形图在更新到 0.6.0 后损坏

Seaborn box plot broken after update to 0.6.0

我最近将我的 seaborn 从 0.5.1 更新到新的 0.6.0 版本。我一直在使用 seaborn 在 python notebook 中制作箱形图和小提琴图,现在我似乎无法再让我的代码工作了。 Matplotlib plt.boxplot 仍然适用于我的数据。特别是,当我有一组子集大小不同的列表或数组时,问题似乎就会发生。

例如:

import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
x = np.array([1,3,4]), ([1,2])
plt.boxplot(x) #this works



 import numpy as np
 import matplotlib.pyplot as plt
 import seaborn as sns
 x = np.array([1,3,4]), ([1,2])
 sns.boxplot(x) #doesn't work

这是我在尝试 seaborn 箱形图时遇到的错误

ValueError: List of boxplot statistics and `positions` values must have same the length

在新的 seaborn 教程中,它说 sns.boxplot 应该采取 plt.boxplot 所做的一切。有没有人遇到过同样的更新问题?有没有办法使这项工作?如果没有,有没有办法同时安装0.6.0版本和0.5.1版本,并在某些笔记本中调用特定版本?

正如 release notes 中所讨论的那样,API 中的分类图发生了一些变化。

在您的情况下,您只需要明确地将数组列表(从技术上讲是元组)传递给 data 参数:

sns.boxplot(data=x)