Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to scale histplot data from seaborn?

I am trying to plot a histogram for data pa.

I wrote a code:

pa = np.array(pa)
scale = l ** 2
pa /= scale

fig, ax = plt.subplots()
hist = sns.histplot(pa, kde=True)

plt.grid(True)
plt.show()

The problem is that it whatever I do with pa data (scaling or not) the histogram looks the same.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I want to scale it, so the maximum possible value is 1.

>Solution :

Depending on your usecase you might want to set the stat in the histplot function. See the documentation.

The default is ‘count’ but you probably want ‘percent’ or ‘frequency’ (or ‘proportion’)

try:


pa = np.array(pa)
scale = l ** 2
pa /= scale

fig, ax = plt.subplots()
hist = sns.histplot(pa, kde=True, stat='percent')

plt.grid(True)
plt.show()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading