如何画大熊猫散射矩阵?

时间:2016-05-01 01:11:04

标签: python numpy pandas matplotlib plot

Pandas scatter matrix - 是绘制配对功能的工具。例如,我们有着名的Irises数据集。在这种情况下,散点矩阵看起来像这样:

enter image description here

我怎样才能画出黄色的Iris Setosa,蓝色的Virginica和红色的Versicolour?

1 个答案:

答案 0 :(得分:1)

您可以通过c参数

传递颜色向量
iris = datasets.load_iris()
df=pd.DataFrame(iris.data)
colMap={0:"red",1:"blue",2:"yellow"}
cols=list(map(lambda x:colMap.get(x),iris.target))
scatter_matrix(df,  diagonal='hist',c=cols)