Home > Software engineering >  How to fill intervals under KDE curve with different colors
How to fill intervals under KDE curve with different colors

Time:06-18

I am looking for a way to color the intervals below the curve with different colors; on the interval x < 0, I would like to fill the area under the curve with one color and on the interval x >= 0 with another color, like the following image: enter image description here

This is the code for basic kde plot:

fig, (ax1) = plt.subplots(1, 1, figsize = ((plot_size   1.5) * 1,(plot_size   1.5)))
sns.kdeplot(data=pd.DataFrame(w_contrast, columns=['contrast']), x="contrast", ax=ax1);
ax1.set_xlabel(f"Dry Yield Posterior Contrast (kg)");

enter image description here

Is there a way to fill the area under the curve with different colors using seaborn?

CodePudding user response:

  • seaborn is a high level api for matplotlib, so the curve will have to be calculated; similar to, but simpler than this enter image description here

  • Related