Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 17303

How to overlay swarmplot and boxplot for groupdata

$
0
0

I created a grouped dataset a using pandas dataframe. I then set one column as hue, another as the x axis, and another as the y. I wanted to overlay a swarm plot and a boxplot. However, while the boxplots are separated by hue, the swarmplots are directly on top of each other.

Format of my dataframe:

x6y8z10
0D8#PGCLCs
1D8#PGCLCs
2D15#MACS
3D15#MACS
4D21#MACS

Here is what I mean:

import seaborn as snssns.set_theme(style="whitegrid")sns.boxplot(data=hope2, x='x6', y='y8', hue='z10')sns.swarmplot(data=hope2, x='x6', y='y8', hue='z10')

grouped dataset, both a swarmplot and boxplot on top of one anothergrouped dataset, both a swarmplot and boxplot on top of one another

What I want is for the orange swarmplot to be overlayed on the orange boxplot, and the blue swarmplots to be overlayed on the blue boxplots. Any assistance would be appreciated.


Viewing all articles
Browse latest Browse all 17303

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>