Scatterplot with categorical variables#

../_images/scatterplot_categorical.png

seaborn components used: set_theme(), load_dataset(), swarmplot()

import seaborn as sns
sns.set_theme(style="whitegrid", palette="muted")

# Load the penguins dataset
df = sns.load_dataset("penguins")

# Draw a categorical scatterplot to show each observation
ax = sns.swarmplot(data=df, x="body_mass_g", y="sex", hue="species")
ax.set(ylabel="")