I am using "tab10" palette because of its distinct colors blue, green, orange and red.
我用的是“tab10”调色板,因为它的颜色是蓝色、绿色、橙色和红色。
k_clust = KMeans(n_clusters=4, random_state= 35, n_init=1).fit(df_normal)
palette = sns.color_palette("tab10")
sns.pairplot(new_df, hue="clusters", palette=palette)
The number of clusters are only 4 and the palette "tab10" has more than 4 colors. Is there a way to address this UserWarning?
簇的数量只有4个,调色板“tab10”有4种以上的颜色。有没有办法解决这个用户警告问题?
The output is:
输出为:
C:\Users\....\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\seaborn\axisgrid.py:1507: UserWarning: The palette list has more values (10) than needed (4), which may not be intended.
func(x=vector, **plot_kwargs)
更多回答
优秀答案推荐
The docs for color_palette()
say that you can pass n_colors=4
to the call.
COLOR_Palette()的文档表明您可以将n_Colors=4传递给调用。
Try this:
试试这个:
...
palette = sns.color_palette("tab10", n_colors=4) # equal to n_clusters
...
更多回答
我是一名优秀的程序员,十分优秀!