Back to Seaborn

Relplot

doc/_docstrings/relplot.ipynb

0.13.21.5 KB
Original Source
python
import seaborn as sns
import matplotlib.pyplot as plt
sns.set_theme(style="ticks")
python
tips = sns.load_dataset("tips")
tips.head()
python
sns.relplot(data=tips, x="total_bill", y="tip", hue="day")
python
sns.relplot(data=tips, x="total_bill", y="tip", hue="day", col="time")
python
sns.relplot(data=tips, x="total_bill", y="tip", hue="day", col="time", row="sex")
python
sns.relplot(data=tips, x="total_bill", y="tip", hue="time", col="day", col_wrap=2)
python
sns.relplot(
    data=tips, x="total_bill", y="tip", col="time",
    hue="time", size="size", style="sex",
    palette=["b", "r"], sizes=(10, 100)
)
python
fmri = sns.load_dataset("fmri")
fmri.head()
python
sns.relplot(
    data=fmri, x="timepoint", y="signal", col="region",
    hue="event", style="event", kind="line",
)
python
sns.relplot(
    data=fmri,
    x="timepoint", y="signal",
    hue="event", style="event", col="region",
    height=4, aspect=.7, kind="line"
)
python
g = sns.relplot(
    data=fmri,
    x="timepoint", y="signal",
    hue="event", style="event", col="region",
    height=4, aspect=.7, kind="line"
)
(g.map(plt.axhline, y=0, color=".7", dashes=(2, 1), zorder=0)
  .set_axis_labels("Timepoint", "Percent signal change")
  .set_titles("Region: {col_name} cortex")
  .tight_layout(w_pad=0))
python
flights_wide = (
    sns.load_dataset("flights")
    .pivot(index="year", columns="month", values="passengers")
)
python
sns.relplot(data=flights_wide, kind="line")