简体   繁体   中英

Seaborn - categorical variables in x-y axis

I am trying to plot a swarmplot using categorical variables in the XY axis. I used melt to make a dataframe that looks like this:

Day Condition Category value
4   WT        cat1     96.0  
4   WT        cat1     74.0
7   WT        cat1     48.0
7   WT        cat1     79.0
10  WT        cat1     29.0
10  WT        cat1     49.0
4   WT        cat2     50.0
4   WT        cat2     57.0
4   WT        cat2     57.0
7   WT        cat2     75.0
7   WT        cat2     49.0
10  WT        cat2     51.0
10  WT        cat2     71.0
4   WT        cat3     19.0
4   WT        cat3     14.0
7   WT        cat3     54.0
7   WT        cat3     30.0
...

I would like to get a swarmplot showing the 'Category' in the y-axis and the 'Day' in the x-axis. In addition, the number of observations (Column 'value') should correspond to dots in every category per day.

Any help is highly appreciated,

IIUC,

sns.swarmplot(x='Day', y='value', hue='Category', data=df)

Output:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM