在Seaborn FacetGrid中的两个折线图之间实现

时间:2018-09-13 15:52:21

标签: python python-3.x matplotlib seaborn

我可以这样画3条线:

sns.lineplot(x="week", y="mean",    data=df)
sns.lineplot(x="week", y="min",     data=df)
sns.lineplot(x="week", y="max",     data=df)

所以我们在这里有最小最大值和平均值,它们在之前已经过预先计算:

enter image description here

我想要在minmax之间充满色彩,它必须看起来像这样: enter image description here

该怎么做?

1 个答案:

答案 0 :(得分:1)

matplotlib

您正在寻找matplotlib.pyplot.fill_between

ax.fill_between(x, min, max)

有关完整示例,请参见此链接

https://matplotlib.org/2.0.1/examples/pylab_examples/fill_between_demo.html

链接到seaborn

seaborn的特定示例中,您需要首先调用facetgrid函数以用空白图填充facetgrid

只有这样,您才能以matplotlib方式添加行,同时仍然使用漂亮的seaborn格式

请参见seaborn.FacetGrid文档底部的内容,您将发现记录的属性ax。在某些版本中,它也可能是axes

相关问题