gpt4 book ai didi

python - Matplotlib + Seaborn - 两条线颜色相同?

转载 作者:太空狗 更新时间:2023-10-30 00:27:45 24 4
gpt4 key购买 nike

我被困在一件看似简单的事情上。我在 Matplotlib 中使用默认的 seaborn 调色板。我想绘制两条颜色相同的线并且我想定义该颜色。我想使用默认 seaborn 调色板中的颜色,即我想要 seaborn 红色而不是 Matplotlib 默认红色。

这是我的代码片段:

import pylab as plot
import seaborn

t = np.arange(0.0, 2.0, 0.01)
s = np.sin(2*np.pi*t)
plt.plot(t, s, 'r')
plt.plot(t, 2*s, 'r')

如果我使用上面的代码,我会得到 Matplotlib 的默认红色(如预期的那样)。有什么“简单”的方法可以告诉它 seaborn 的红色吗?如果我不定义颜色,颜色将在 seaborn 的默认颜色循环中循环。谢谢!

最佳答案

在 seaborn 0.6 或更高版本中,您可以调用 seaborn.set_color_codes()seaborn.set(color_codes=True)"r" 将被解释为默认的 seaborn 红色。

关于python - Matplotlib + Seaborn - 两条线颜色相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33514601/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com