Raincloud Plot#
import pandas as pd
from lets_plot import *
LetsPlot.setup_html()
df = pd.read_csv("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/refs/heads/master/data/penguins.csv")
print(df.shape)
df.head()
(344, 7)
| species | island | bill_length_mm | bill_depth_mm | flipper_length_mm | body_mass_g | sex | |
|---|---|---|---|---|---|---|---|
| 0 | Adelie | Torgersen | 39.1 | 18.7 | 181.0 | 3750.0 | male |
| 1 | Adelie | Torgersen | 39.5 | 17.4 | 186.0 | 3800.0 | female |
| 2 | Adelie | Torgersen | 40.3 | 18.0 | 195.0 | 3250.0 | female |
| 3 | Adelie | Torgersen | NaN | NaN | NaN | NaN | NaN |
| 4 | Adelie | Torgersen | 36.7 | 19.3 | 193.0 | 3450.0 | female |
ggplot(df, aes("species", "bill_depth_mm", color="species", fill="species")) + \
geom_violin(show_half=1, alpha=.75, trim=False,
position=position_nudge(x=.07),
tooltips=layer_tooltips().format("@..violinwidth..", ".3~g")) + \
geom_sina(show_half=-1, fill="white", shape=21, seed=42, show_legend=False,
position=position_nudge(x=-.07)) + \
geom_boxplot(width=.1, outlier_alpha=0, show_legend=False) + \
scale_color_brewer(palette="Set2") + \
scale_fill_brewer(palette="Pastel2") + \
coord_flip() + \
ylab("bill depth (mm)") + \
theme_light() + \
flavor_solarized_dark() + \
ggsize(800, 600)