Issue
I have a dataset like:
Count ID size
0 25 0001 1
1 4 0001 2
2 9 0001 3
3 13 0001 4
4 19 0001 5
...
8 11 0003 10
9 10 0003 12
10 7 0003 14
11 15 0003 16
The objective is to plot a histogram for each unique ID, with the size on the x-axis as the boxes and the count on the y-axis is count. I've tried using the following code:
df = pd.DataFrame(data)
for d in df.groupby(df['ID']):
plt.hist(d[1][['size','Count']])
plt.show()
However, this does not give me the desired result as this is the way to plot a normal graph but not a histogram. Unfortunately, I have not been able to figure out how to tackle this problem.
Solution
I think you might want barplots, not histplots.
You can use seaborn.catplot
:
import seaborn as sns
sns.catplot(data=df, x='size', y='Count', col='ID', kind='bar')
Answered By - mozway
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.