Seaborn pairplot 数据未显示
Seaborn pairplot data not shown
我决定尝试 Seaborn 的 pairplot,但是下面的代码行 (https://stanford.edu/~mwaskom/software/seaborn/generated/seaborn.pairplot.html) 给出了一个没有数据出现的图:
>>> import matplotlib.pyplot as plt
>>> import seaborn as sns; sns.set(style="ticks", color_codes=True)
>>> sns.set(font='monospace')
>>> iris = sns.load_dataset("iris")
>>> g = sns.pairplot(iris)
>>> plt.show()
我的剧情是怎么回事?
你可以试试:
- 卸载seaborn,然后重新安装seaborn
- 卸载matplotlib和seaborn,然后重新安装matplotlib,然后重新安装seaborn。
您在 matplotlib 1.3 中遇到了一个错误。解决方案是升级您的 matplotlib。
如果您由于某种原因无法升级 matplotlib,可以使用此解决方法,它会在 matplotlib 1.3.1 中生成几乎所需的图:
g = sns.PairGrid(iris)
def scatter_fake_diag(x, y, *a, **kw):
if x.equals(y):
kw["color"] = (0, 0, 0, 0)
plt.scatter(x, y, *a, **kw)
g.map(scatter_fake_diag)
g.map_diag(plt.hist)
我决定尝试 Seaborn 的 pairplot,但是下面的代码行 (https://stanford.edu/~mwaskom/software/seaborn/generated/seaborn.pairplot.html) 给出了一个没有数据出现的图:
>>> import matplotlib.pyplot as plt
>>> import seaborn as sns; sns.set(style="ticks", color_codes=True)
>>> sns.set(font='monospace')
>>> iris = sns.load_dataset("iris")
>>> g = sns.pairplot(iris)
>>> plt.show()
我的剧情是怎么回事?
你可以试试:
- 卸载seaborn,然后重新安装seaborn
- 卸载matplotlib和seaborn,然后重新安装matplotlib,然后重新安装seaborn。
您在 matplotlib 1.3 中遇到了一个错误。解决方案是升级您的 matplotlib。
如果您由于某种原因无法升级 matplotlib,可以使用此解决方法,它会在 matplotlib 1.3.1 中生成几乎所需的图:
g = sns.PairGrid(iris)
def scatter_fake_diag(x, y, *a, **kw):
if x.equals(y):
kw["color"] = (0, 0, 0, 0)
plt.scatter(x, y, *a, **kw)
g.map(scatter_fake_diag)
g.map_diag(plt.hist)