简体   繁体   English

此字符串在seaborn散点图的Palette参数中意味着什么?

[英]What does this string mean in the palette argument for seaborn scatterplot?

From seaborn gallery - scatter plots , seaborn画廊-散点图

import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="whitegrid")

# Load the example iris dataset
diamonds = sns.load_dataset("diamonds")

# Draw a scatter plot while assigning point colors and sizes to different
# variables in the dataset
f, ax = plt.subplots(figsize=(6.5, 6.5))
sns.despine(f, left=True, bottom=True)
clarity_ranking = ["I1", "SI2", "SI1", "VS2", "VS1", "VVS2", "VVS1", "IF"]
sns.scatterplot(x="carat", y="price",
                hue="clarity", size="depth",
                palette="ch:r=-.2,d=.3_r",
                hue_order=clarity_ranking,
                sizes=(1, 8), linewidth=0,
                data=diamonds, ax=ax)

What does this cryptic string "ch:r=-.2,d=.3_r" mean? 这个神秘的字符串"ch:r=-.2,d=.3_r"是什么意思?

The only reference I can find is on seaborn.color_palette 's doc, saying that 我可以找到的唯一参考是seaborn.color_palette的文档,说

 Other options: name of matplotlib cmap, 'ch:<cubehelix arguments>', 'hls', 'husl', or a list of colors in any format matplotlib accepts 

But still cannot find anything in matplotlib doc. 但仍然无法在matplotlib文档中找到任何内容。

So, what does it mean exactly? 那么,这到底是什么意思呢? So far I only know the suffix _r means 'reverse' of hues. 到目前为止,我只知道后缀_r表示色调的“反向”。

The "ch:r=-.2,d=.3_r" syntax is seaborn specific. "ch:r=-.2,d=.3_r"语法是特定于语言的。 So no wonder there is nothing about it in the matplotlib docs. 因此,难怪matplotlib文档中对此一无所知。

Possible options of <cubehelix arguments> in 'ch:<cubehelix arguments>' can implicitely be deduced from the seaborn.cubehelix_palette documentation. 可以从seaborn.cubehelix_palette文档中隐式推断出'ch:<cubehelix arguments>'<cubehelix arguments>可能选项。

This provides arguments like 这提供了像

 start : float, 0 <= start <= 3 The hue at the start of the helix. rot : float Rotations around the hue wheel over the range of the palette. gamma : float 0 <= gamma Gamma factor to emphasize darker (gamma < 1) or lighter (gamma > 1) colors. hue : float, 0 <= hue <= 1 Saturation of the colors. dark : float 0 <= dark <= 1 Intensity of the darkest color in the palette. light : float 0 <= light <= 1 Intensity of the lightest color in the palette. 

You can use those in the string like 您可以在字符串中使用类似

"ch:rot=-0.2,dark=0.3"

and in order to shorten this, using only the first letter is sufficient 为了缩短时间,仅使用第一个字母就足够了

"ch:r=-0.2,d=0.3"

Note that it is not possible to select the number of colors through this string mini language. 请注意,无法通过此字符串迷你语言选择颜色数量。

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

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