Back to Seaborn

Barplot

doc/_docstrings/barplot.ipynb

0.13.21.4 KB
Original Source
python
import seaborn as sns
sns.set_theme(style="whitegrid")
penguins = sns.load_dataset("penguins")
flights = sns.load_dataset("flights")
python
sns.barplot(penguins, x="island", y="body_mass_g")
python
sns.barplot(penguins, x="body_mass_g", y="island", hue="island", legend=False)
python
flights_wide = flights.pivot(index="year", columns="month", values="passengers")
sns.barplot(flights_wide)
python
sns.barplot(flights_wide["Jun"])
python
sns.barplot(penguins, x="island", y="body_mass_g", hue="sex")
python
sns.barplot(penguins, x="island", y="body_mass_g", errorbar="sd")
python
sns.barplot(flights, x="year", y="passengers", estimator="sum", errorbar=None)
python
ax = sns.barplot(flights, x="year", y="passengers", estimator="sum", errorbar=None)
ax.bar_label(ax.containers[0], fontsize=10);
python
ax = sns.barplot(
    flights, x="year", y="passengers",
    native_scale=True,
    estimator="sum", errorbar=None,
)
ax.plot(1955, 3600, "*", markersize=10, color="r")
python
sns.barplot(flights, x="passengers", y="year", orient="y")
python
sns.barplot(
    penguins, x="body_mass_g", y="island",
    errorbar=("pi", 50), capsize=.4,
    err_kws={"color": ".5", "linewidth": 2.5},
    linewidth=2.5, edgecolor=".5", facecolor=(0, 0, 0, 0),
)
python
sns.catplot(
    penguins, kind="bar",
    x="sex", y="body_mass_g", col="species",
    height=4, aspect=.5,
)