官方参考文档:
http://seaborn.pydata.org/tutorial/color_palettes.html
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
# 绘图,figsize设置大小
def sinplot():
x = np.linspace(0,14,100)
plt.figure(figsize=(8,6))
for i in range(4):
plt.plot(x,np.sin(x+i)*(i+0.75), label='sin(x+%s)*(%s+0.75)' % (i,i))
plt.legend()
sinplot()
# 导入seaborn
import seaborn as sns
sns.set()
sinplot()
# 当前画板
sns.color_palette() #RGB列表元组
[(0.29803921568627451, 0.44705882352941179, 0.69019607843137254),
(0.33333333333333331, 0.6588235294117647, 0.40784313725490196),
(0.7686274509803922, 0.30588235294117649, 0.32156862745098042),
(0.50588235294117645, 0.44705882352941179, 0.69803921568627447),
(0.80000000000000004, 0.72549019607843135, 0.45490196078431372),
(0.39215686274509803, 0.70980392156862748, 0.80392156862745101)]
# 显示画板
sns.palplot(sns.color_palette())
# 自带风格
pal_style = ['deep', 'muted', 'pastel', 'bright', 'dark','colorblind']
sns.palplot(sns.color_palette('dark'))
# 设置画板
sns.set_palette(sns.color_palette('dark'))
sinplot()
# 清空画板
sns.set()
sinplot()
# 局部使用画板with语句,外部还是系统画板
with sns.color_palette('dark'):
sinplot()
# 外部没变
sinplot()
# 自定义画板
pall = sns.color_palette([(0.1,0.2,0.3),(0.9,0.3,0.6),(0.3,0.3,0.3)])
sns.palplot(pall)
# 自动生成画板
sc = sns.color_palette('hls', 10)
sns.palplot(sc)
sns.set_palette(sc)
sinplot()