Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
426 views
in Technique[技术] by (71.8m points)

python - Is there a way to show the probability within hue category in Seaborn histogram

For example, I have a dataframe:

data = {'1': [1, 1, 2,2,2,2,2, 3,2.5,2.5,1.5,2,2.5,2, 2, 3,1.5,2],
       '2': [1,1,1,1,1,1,1,1,1,1,1,1,1,1,0, 0,0,0],
       }
df = pd.DataFrame(data).T
df

df

I would like to draw a histogram in Seaborn,

import seaborn as sns
sns.histplot(data=df, x="1", hue='2',stat='probability')

histogram

Due to class 0 having few records, the bar is quite low (I want it's max height the same as class 1) even if I add a "stat" parameter of 'probability'.

It's because it's the "probability" out of total, is there another kind of "probability" exactly out of the hue category (0 and 1 here)?

question from:https://stackoverflow.com/questions/65948859/is-there-a-way-to-show-the-probability-within-hue-category-in-seaborn-histogram

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...