Back to Seaborn

Violinplot

doc/_docstrings/violinplot.ipynb

0.13.21.4 KB
Original Source
python
import seaborn as sns
sns.set_theme(style="whitegrid")
python
df = sns.load_dataset("titanic")
sns.violinplot(x=df["age"])
python
sns.violinplot(data=df, x="age", y="class")
python
sns.violinplot(data=df, x="class", y="age", hue="alive")
python
sns.violinplot(data=df, x="class", y="age", hue="alive", fill=False)
python
sns.violinplot(data=df, x="class", y="age", hue="alive", split=True, inner="quart")
python
sns.violinplot(data=df, x="class", y="age", hue="alive", split=True, gap=.1, inner="quart")
python
sns.violinplot(data=df, x="class", y="age", split=True, inner="quart")
python
sns.violinplot(data=df, x="age", y="deck", inner="point")
python
sns.violinplot(data=df, x="age", y="deck", inner="point", density_norm="count")
python
sns.violinplot(data=df, x="age", y="alive", cut=0, inner="stick")
python
sns.violinplot(data=df, x="age", y="alive", bw_adjust=.5, inner="stick")
python
sns.violinplot(x=df["age"].round(-1) + 5, y=df["fare"], native_scale=True)
python
decades = lambda x: f"{int(x)}{int(x + 10)}"
sns.violinplot(x=df["age"].round(-1), y=df["fare"], formatter=decades)
python
sns.violinplot(data=df, x="age", linewidth=1, linecolor="k")
python
sns.violinplot(data=df, x="age", inner_kws=dict(box_width=15, whis_width=2, color=".8"))