有一个参数palette 用于定义颜色,palette 只是定义为tuples 的颜色列表,其中包含 3 个介于 0 和 1 之间的值。
如果你有一种颜色,你可以使用:
palette=[(r_rl/255, g_rl/255, b_rl/255)]
但对于多种颜色:
rgb = [(66, 135, 245), (255, 25, 0)] # first blue, second red
colors = [tuple(t / 255 for t in x) for x in rgb]
然后使用:
sns.lineplot(
x="Episode",
y="Mean Reward",
sizes=(0.25, 0.25),
hue="Agent",
data=df[0],
palette=colors,
)
随机示例:
import seaborn as sns
import matplotlib.pyplot as plt
rgb = [(66, 135, 245), (255, 25, 0)]
colors = [tuple(t / 255 for t in x) for x in rgb]
sns.set()
fmri = sns.load_dataset("fmri")
ax = sns.lineplot(
x="timepoint",
y="signal",
hue="event",
data=fmri,
palette=colors,
)
结果: