50.md 1.1 KB
Newer Older
C
Cancan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
# seaborn.set_color_codes

```python
seaborn.set_color_codes(palette='deep')
```

改变matplotlib颜色缩写词的解释方式。

调用此方法将改变matplotlib在后续图表中解释缩写词,例如"b"或"g"的方式。

参数: `palette`: {deep, muted, pastel, dark, bright, colorblind}

> 预命名的seaborn调色板,用作颜色的来源

参见

可以通过高级seaborn样式管理器设置颜色代码。也可以通过设置matplotlib颜色循环功能设置颜色代码。

示例:

将matplotlib颜色代码映射到默认的seaborn调色板。

```python
>>> import matplotlib.pyplot as plt
>>> import seaborn as sns; sns.set()
>>> sns.set_color_codes()
>>> _ = plt.plot([0, 1], color="r")
```

![http://seaborn.pydata.org/_images/seaborn-set_color_codes-1.png](img/f7331a33eaedf9eae59191642f7a64e4.jpg)

使用不同的seaborn调色板

```python
>>> sns.set_color_codes("dark")
>>> _ = plt.plot([0, 1], color="g")
>>> _ = plt.plot([0, 2], color="m")
```

![http://seaborn.pydata.org/_images/seaborn-set_color_codes-2.png](img/35544ecf6de962c91ab860527035f39f.jpg)