海伯恩的怪事和我该怎么纠正

2024-04-19 07:13:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用的是Python 2.7.15、seaborn 0.9.0和matplotlib 2.0.2

当我试着用seaborn scatterplot函数绘制4个点时,所有的点都有不同的颜色:

import seaborn as sns
sns.scatterplot(x=range(4), y=[1]*4)

enter image description here

如果我用3或5个点做同样的事情,那就是所有的颜色都一样。你知道吗

import seaborn as sns
sns.scatterplot(x=range(5), y=[1]*5)

enter image description here

有人知道这是有(好的)原因还是一个bug吗?你知道吗

但更重要的是,我要怎么做才能得到相同的颜色为所有的4点?你知道吗

PS:我无法在Python3.7中复制这个


Tags: 函数importmatplotlib颜色as绘制range原因