在用seaborn画折线图时,一张图中的多条线颜色十分接近。如下图,根本看不清
sns.lineplot有一个参数是palette,意思是“调色板”。
官网:https://seaborn.pydata.org/generated/seaborn.lineplot.html
该参数可以为string、list、dict、或者是matplotlib.colors.Colormap
举个例子:
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
data = pd.read_csv("data.csv")
action_set = data['action'].unique().tolist()
plt.figure(figsize=(25, 10))
palette = sns.color_palette("bright", len(action_set))
sns.lineplot(x="time", y="count",hue="action",err_style="bars", ci=68, data=data, palette=palette)
plt.show()
palette = sns.xkcd_palette(["windows blue", "amber", "greyish", "faded green", "dusty purple", "red", "black"])