Skip to content Skip to sidebar Skip to footer

How Do I Change Y-axis Limits In Seaborn Histogram?

I have highly imbalanced raw data, which looks like: df Index Branch 1 10000 2 200 ... 1000 1 ... 10000 1 And if I run: import seaborn as sns sns.distplot(df['Branc

Solution 1:

seaborn uses matplotlib under the hood so you can just

import matplotlib.pyplotas plt
import seaborn as sns

sns.distplot(df['Branch'], bins=1000)
plt.ylim(0, 0.06)

Same for x-axis:

plt.xlim(0, 500)

Also the usual plt.show() to mute the undesired printout: Out[60]: (0, 0.4)

EDIT : Yes, it doesn't change the curve or the area under it. It only changes the boundaries of the "picture". I made the test, you can see below that the cumulative distribution curve is on the scale of the data, and not the image. If it did, the cumulative line (orange) would have reached 100% at the right of the image. I did this by adding kde_kws={'cumulative':True}. enter image description here

Post a Comment for "How Do I Change Y-axis Limits In Seaborn Histogram?"