提交 861c72d9 编写于 作者: J Joseph.L.Meng

Saved 54.md with Dillinger.io

上级 8b25ae6e
......@@ -4,54 +4,55 @@
seaborn.color_palette(palette=None, n_colors=None, desat=None)
```
Return a list of colors defining a color palette.
返回一个颜色列表来定义一个调色板。
```py
Available seaborn palette names:
```
deep, muted, bright, pastel, dark, colorblind
有 deep, muted, bright, pastel, dark, colorblind 六种颜色模式
```py
Other options:
```
name of matplotlib cmap, ‘ch:<cubehelix arguments>’, ‘hls’, ‘husl’, or a list of colors in any format matplotlib accepts
matplotlib Colormap 的名字、‘ch:<cubehelix arguments>’, ‘hls’, ‘husl’,或任一 matplotlib 接受的不同格式颜色列表。
Calling this function with `palette=None` will return the current matplotlib color cycle.
调用此函数并设置 `palette=None` 会返回当前 matplotlib 色彩循环。
Matplotlib palettes can be specified as reversed palettes by appending “_r” to the name or as “dark” palettes by appending “_d” to the name. (These options are mutually exclusive, but the resulting list of colors can also be reversed).
matplotlib 调色板的顺序可以通过在调色板名称后添加 “_r” 来倒置,同样,添加 “_d” 可以将调色板设置为深色模式。(这些选项为互斥属性,返回的颜色列表同样可以被取反)
This function can also be used in a `with` statement to temporarily set the color cycle for a plot or set of plots.
可以在 `with` 语句中使用此函数来为一个或多个点临时改变调色板。
See the [tutorial](../tutorial/color_palettes.html#palette-tutorial) for more information.
参考这篇 [教程](../tutorial/color_palettes.html#palette-tutorial) 来获取更多信息。
参数:**palette:None, string, or sequence, optional**
> Name of palette or None to return current palette. If a sequence, input colors are used but possibly cycled and desaturated.
> 调色板或者 None 值来返回给当前调色板。如果是序列,输入颜色会被使用,可能会被循环化并降低饱和度。
`n_colors`:int, optional
> Number of colors in the palette. If `None`, the default will depend on how `palette` is specified. Named palettes default to 6 colors, but grabbing the current palette or passing in a list of colors will not change the number of colors unless this is specified. Asking for more colors than exist in the palette will cause it to cycle.
`n_colors`:int, 可选
`desat`:float, optional
> 调色板中的颜色数。如果为 None,则默认值将取决于调色板的指定方式。已命名调色板默认有 6 种颜色,抓取当前调色板或传递颜色列表不会更改颜色数,除非作出指定。要求比调色板中存在的颜色更多的颜色会导致调色板循环化。
> Proportion to desaturate each color by.
`desat`:float, 可选
> 每种颜色的去饱和比例。
返回值:`palette`:list of RGB tuples.
> Color palette. Behaves like a list, but can be used as a context manager and possesses an `as_hex` method to convert to hex color codes.
返回值:`palette`:RGB 元组序列。
> 调色板。操作类似于列表,但可以用作上下文管理器,并具有转换为十六进制颜色代码的 `as_hex` 方法。
See also
Set the default color cycle for all plots.Reassign color codes like `"b"`, `"g"`, etc. to colors from one of the seaborn palettes.
另外
Examples
设置所有的默认颜色循环。重新分配颜色代码,如 “b”、“g” 等。从seaborn 调色板中选择颜色。
Calling with no arguments returns all colors from the current default color cycle:
例子
不带参数的调用将返回当前默认颜色循环中的所有颜色:
```py
>>> import seaborn as sns; sns.set()
......@@ -61,7 +62,7 @@ Calling with no arguments returns all colors from the current default color cycl
![http://seaborn.pydata.org/_images/seaborn-color_palette-1.png](img/9a5bb2b7fbd94af1db1d911dfbec1f7c.jpg)
Show one of the other “seaborn palettes”, which have the same basic order of hues as the default matplotlib color cycle but more attractive colors. Calling with the name of a palette will return 6 colors by default:
显示另一个 “seaborn 调色板”,具有与默认 matplotlib 颜色循环相同的基本色调顺序,但颜色更吸引人。默认情况下,使用调色板名称进行调用将返回6种颜色:
```py
>>> sns.palplot(sns.color_palette("muted"))
......@@ -70,7 +71,7 @@ Show one of the other “seaborn palettes”, which have the same basic order of
![http://seaborn.pydata.org/_images/seaborn-color_palette-2.png](img/f675cc14d11fb5585e5b1829cb29b569.jpg)
Use discrete values from one of the built-in matplotlib colormaps:
使用一个内置 matplotlib clolormap 的离散值:
```py
>>> sns.palplot(sns.color_palette("RdBu", n_colors=7))
......@@ -79,7 +80,7 @@ Use discrete values from one of the built-in matplotlib colormaps:
![http://seaborn.pydata.org/_images/seaborn-color_palette-3.png](img/0aa3ba1dbc0e103e4d7b96c4de278ec9.jpg)
Make a customized cubehelix color palette:
创建自定义立方体螺旋线调色板:
```py
>>> sns.palplot(sns.color_palette("ch:2.5,-.2,dark=.3"))
......@@ -88,7 +89,7 @@ Make a customized cubehelix color palette:
![http://seaborn.pydata.org/_images/seaborn-color_palette-4.png](img/6e3b5f94591e119cae1ead4b24d26c9e.jpg)
Use a categorical matplotlib palette and add some desaturation:
使用一个明确的 matplotlib 调色板并降低一些饱和度:
```py
>>> sns.palplot(sns.color_palette("Set1", n_colors=8, desat=.5))
......@@ -97,7 +98,7 @@ Use a categorical matplotlib palette and add some desaturation:
![http://seaborn.pydata.org/_images/seaborn-color_palette-5.png](img/ce60a356e2dcd3cbe9cc67f1128c09c7.jpg)
Make a “dark” matplotlib sequential palette variant. (This can be good when coloring multiple lines or points that correspond to an ordered variable, where you don’t want the lightest lines to be invisible):
创建 “dark”(深色)matplotlib 顺序调色板变体。(当对应于有序变量的多条线或点进行着色时,如果您不希望最轻的线不可见,则可以使用此选项):
```py
>>> sns.palplot(sns.color_palette("Blues_d"))
......@@ -106,7 +107,7 @@ Make a “dark” matplotlib sequential palette variant. (This can be good when
![http://seaborn.pydata.org/_images/seaborn-color_palette-6.png](img/fcc8ab8bf79674eb14cd31eead15dfd1.jpg)
Use as a context manager:
作为上下文管理器使用:
```py
>>> import numpy as np, matplotlib.pyplot as plt
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册