[英]Seaborn Color Palette not working appropiate with lineplot
我在為線條圖自定義顏色時遇到了一些麻煩。 我想用順序調色板顯示一組光譜。 參數 "palette="blues" 工作正常,但不接受任何適當的顏色列表(如 "Blues_d"),其中不包括任何亮色。
您可以在下面看到我正在使用的代碼。
color = (sns.dark_palette("purple"))
sns.set()
ax = sns.lineplot(x="Wavelength", y="Absorption", hue="t (min)", lw=1, data=df1, palette=color, legend="brief")
由於您在hue
選項中提到了t (min)
列,因此您需要知道該列的唯一值的總數。
假設列中有 5 個唯一值。 你,因此,可以設置成數n_colors
的選項sns.color_palette
:
ax = sns.lineplot(x="Wavelength",
y="Absorption",
hue="t (min)",
lw=1,
data=df1,
palette=sns.color_palette('coolwarm', n_colors=5),
legend="brief")
如果您通過在 sns.color_palette 中將“as_cmap”參數設置為 True 將調色板設置為顏色圖,則無需擔心顏色計數:
ax = sns.lineplot(x="Wavelength",
y="Absorption",
hue="t (min)",
lw=1,
data=df1,
palette=sns.color_palette('coolwarm', as_cmap = True),
legend="brief")
Palette = ["#090364", "#091e75"] #define your preference
sns.set_style("whitegrid")
sns.set_palette(Palette) #use the list defined in the function
plot = sns.countplot(df['Purchased']) #Enjoy ploting
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.