Skip to content Skip to sidebar Skip to footer

Color The Shaded Area Under The Curve Distribution Plot Different Colors

I'm using seaborn's kdeplot to draw the distribution of my data. sns.kdeplot(data['numbers'], shade=True) I want to divide the shaded area under the line into three parts, showing

Solution 1:

So I figured out how to do it. I would retrieve and x and y arrays from the seaborn plot, then use fill_between to color under the curve.

points = sns.kdeplot(data['numbers'], shade=True).get_lines()[0].get_data()

x = points[0]
y = points[1]

plt.fill_between(x,y, where = x >=0.75, color='r')
plt.fill_between(x,y, where = x <=0.1, color='g')
plt.fill_between(x,y, where = (x<=0.75) & (x>=0.1), color='y')

Post a Comment for "Color The Shaded Area Under The Curve Distribution Plot Different Colors"