简体   繁体   English

如何在创建散点图矩阵时更改seaborn中的颜色优先级

[英]how to change colour priority in seaborn while creating scatter plot matrix

I am creating a scatter plot using following code:我正在使用以下代码创建散点图:

import seaborn as sns
sns.set(style="ticks")
sns.pairplot(visualdf, hue="Target")

I have the output category in target, so I am getting 3 colours, red, blue and green.我在目标中有输出类别,所以我得到 3 种颜色,红色、蓝色和绿色。 As red is 95 percent of total points, blue 4 percent and green 1 percent.因为红色占总分的 95%,蓝色占总分的 4%,绿色占总分的 1%。

The data points are overlapping because of this.因此,数据点重叠。

I want to set the priority on colours that green will be on top priority followed by blue and red.我想设置颜色的优先级,绿色将是最高优先级,然后是蓝色和红色。 So if it's overlap, it will display the top priority column.因此,如果它重叠,它将显示最高优先级列。

How to do this in efficient way.如何以有效的方式做到这一点。

You can do something like this:你可以这样做:

import seaborn as sns
sns.set(style="ticks")
visuald_otherOrder = visuald.sort_values(by=['Target'], ascending=False)
sns.pairplot(visualdf_otherOrder, hue="Target")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM