我想用seaborn进行测试以显示一些玩具数据。 python代码如下:
import numpy as np
from pandas import DataFrame
import seaborn as sns
from sklearn.datasets import make_classification
def test_seaborn():
X, y = make_classification(n_samples=1000,
n_features=20,
n_informative=2,
n_redundant=2,
n_classes=2,
random_state=0)
df = DataFrame(np.hstack((X, y[:, None])),
columns = range(20) + ["class"])
sns.pairplot(df[:50],
vars=[8, 11, 12, 14, 19],
hue="class",
size=1.5)
sns.plt.show()
if __name__=='__main__':
test_seaborn()
在一些指南中,情节应如下所示:(每个模块中显示近 50 个点) enter image description here 实际上,我得到了这样的情节(几点): enter image description here
顺便说一句,环境信息: 发行商 ID:Ubuntu 说明:Ubuntu 14.04.3 LTS numpy:1.10.4 scikit学习:0.17 Seaborn:0.7.0
你能帮我吗?谢谢!
最佳答案
您在 matplotlib 1.3 中遇到了错误。解决方案是升级您的 matplotlib。如果您不想这样做,则必须手动设置每行和每列的轴限制。
关于Python Seaborn 不显示所有数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35422753/