gpt4 book ai didi

How can I resolve "UserWarning: The palette list has more values (10) than needed (4), which may not be intended"?(如何解析“UserWarning:调色板列表的值(10)多于所需的值(4),这可能不是故意的”?)

转载 作者:bug小助手 更新时间:2023-10-24 21:22:52 28 4
gpt4 key购买 nike



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)

更多回答

As shown in these duplicates, How to make a color map with many unique colors in seaborn and Seaborn palettes - prevent recycling of colors, set n_colors=: palette = sns.color_palette("tab10", n_colors=4)). Don't know why it was unduped, because the question boils down to, how do I set the number of colors in the palette.

如这些副本中所示,如何在海运和海运调色板中制作具有许多独特颜色的色彩映射表-防止颜色重复使用,设置n_Colors=:Palette=Sns.COLOR_PALET(“tab10”,n_Colors=4))。不知道为什么它没有被复制,因为问题归结为,我如何设置调色板中的颜色数量。

I would vote as duplicate again. stackoverflow.com/users/1533576/mwaskom caused undupe and reopen.

我会再次投票作为副本。STACKOVERFLO.com/USERS/1533576/MWASKOM导致取消重复并重新打开。

优秀答案推荐

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
...

更多回答

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com