import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
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
sinplot()

【数据分析可视化】seaborn强大的调色功能_其他_02

# 调色板 RGB
sns.color_palette() 
[(0.12156862745098039, 0.4666666666666667, 0.7058823529411765),
 (1.0, 0.4980392156862745, 0.054901960784313725),
 (0.17254901960784313, 0.6274509803921569, 0.17254901960784313),
 (0.8392156862745098, 0.15294117647058825, 0.1568627450980392),
 (0.5803921568627451, 0.403921568627451, 0.7411764705882353),
 (0.5490196078431373, 0.33725490196078434, 0.29411764705882354),
 (0.8901960784313725, 0.4666666666666667, 0.7607843137254902),
 (0.4980392156862745, 0.4980392156862745, 0.4980392156862745),
 (0.7372549019607844, 0.7411764705882353, 0.13333333333333333),
 (0.09019607843137255, 0.7450980392156863, 0.8117647058823529)]
sns.palplot(sns.color_palette())

【数据分析可视化】seaborn强大的调色功能_其他_03

pal_style = ['deep','muted','pastel','bright', 'dark', 'colorblind']
# 定义色板
sns.palplot(sns.color_palette('dark'))

【数据分析可视化】seaborn强大的调色功能_官网_04

sns.set_palette(sns.color_palette('dark'))
sinplot()

【数据分析可视化】seaborn强大的调色功能_官网_05

# 恢复默认状态
sns.set()
sinplot()

【数据分析可视化】seaborn强大的调色功能_官网_06

# 当前范围内 指定色板
with sns.color_palette('dark'):
    sinplot()

【数据分析可视化】seaborn强大的调色功能_其他_07

sinplot()

【数据分析可视化】seaborn强大的调色功能_其他_08

# 突破色板是6的限制
pal_1 = sns.color_palette([(0.5,0.1,0.7),(0.3,0.1,0.9)])
pal_1
[(0.5, 0.1, 0.7), (0.3, 0.1, 0.9)]
sns.palplot(pal_1)

【数据分析可视化】seaborn强大的调色功能_官网_09

# 快捷定义颜色
sns.color_palette('hls', 8)
[(0.86, 0.3712, 0.33999999999999997),
 (0.86, 0.7612000000000001, 0.33999999999999997),
 (0.5688000000000001, 0.86, 0.33999999999999997),
 (0.33999999999999997, 0.86, 0.5012000000000001),
 (0.33999999999999997, 0.8287999999999999, 0.86),
 (0.33999999999999997, 0.43879999999999986, 0.86),
 (0.6311999999999998, 0.33999999999999997, 0.86),
 (0.86, 0.33999999999999997, 0.6987999999999996)]
sns.palplot(sns.color_palette('hls', 8))

【数据分析可视化】seaborn强大的调色功能_官网_10

 
官网

【数据分析可视化】seaborn强大的调色功能_官网_11