Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fulfill between two lineschart in seaborn FacetGrid [duplicate]

I can draw 3 lines this way:

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

So we have here min max and average value, they have precomputed before:

enter image description here

I want want fulfill with color between min and max, it have to look this way: enter image description here

How to do that?

like image 602
Rocketq Avatar asked Oct 28 '25 12:10

Rocketq


1 Answers

matplotlib

You are looking for matplotlib.pyplot.fill_between

ax.fill_between(x, min, max)

see this link for a full example

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

Link to seaborn

In the specific example of seaborn you need to first call the facetgrid function to populate the facetgrid with a blank plot.

Only then you can add lines in a matplotlib way whilst still using pretty seaborn formatting

See right at the bottom of the seaborn.FacetGrid docs and you will find an Attribute ax documented. In some versions this might also be axes

like image 66
Alexander McFarlane Avatar answered Oct 31 '25 02:10

Alexander McFarlane



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!