doc/_docstrings/boxplot.ipynb
import seaborn as sns
sns.set_theme(style="whitegrid")
titanic = sns.load_dataset("titanic")
sns.boxplot(x=titanic["age"])
sns.boxplot(data=titanic, x="age", y="class")
sns.boxplot(data=titanic, x="class", y="age", hue="alive")
sns.boxplot(data=titanic, x="class", y="age", hue="alive", fill=False, gap=.1)
sns.boxplot(data=titanic, x="age", y="deck", whis=(0, 100))
sns.boxplot(data=titanic, x="age", y="deck", width=.5)
sns.boxplot(data=titanic, x="age", y="deck", color=".8", linecolor="#137", linewidth=.75)
Group by a numeric variable and preserve its native scaling:
ax = sns.boxplot(x=titanic["age"].round(-1), y=titanic["fare"], native_scale=True)
ax.axvline(25, color=".3", dashes=(2, 2))
sns.boxplot(
data=titanic, x="age", y="class",
notch=True, showcaps=False,
flierprops={"marker": "x"},
boxprops={"facecolor": (.3, .5, .7, .5)},
medianprops={"color": "r", "linewidth": 2},
)