Back to Seaborn

Aesthetics

doc/_tutorial/aesthetics.ipynb

0.13.21.7 KB
Original Source
python
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
python
%matplotlib inline
np.random.seed(sum(map(ord, "aesthetics")))
python
def sinplot(n=10, flip=1):
    x = np.linspace(0, 14, 100)
    for i in range(1, n + 1):
        plt.plot(x, np.sin(x + i * .5) * (n + 2 - i) * flip)
python
sinplot()
python
sns.set_theme()
sinplot()
python
sns.set_style("whitegrid")
data = np.random.normal(size=(20, 6)) + np.arange(6) / 2
sns.boxplot(data=data);
python
sns.set_style("dark")
sinplot()
python
sns.set_style("white")
sinplot()
python
sns.set_style("ticks")
sinplot()
python
sinplot()
sns.despine()
python
f, ax = plt.subplots()
sns.violinplot(data=data)
sns.despine(offset=10, trim=True);
python
sns.set_style("whitegrid")
sns.boxplot(data=data, palette="deep")
sns.despine(left=True)
python
f = plt.figure(figsize=(6, 6))
gs = f.add_gridspec(2, 2)

with sns.axes_style("darkgrid"):
    ax = f.add_subplot(gs[0, 0])
    sinplot(6)
    
with sns.axes_style("white"):
    ax = f.add_subplot(gs[0, 1])
    sinplot(6)

with sns.axes_style("ticks"):
    ax = f.add_subplot(gs[1, 0])
    sinplot(6)

with sns.axes_style("whitegrid"):
    ax = f.add_subplot(gs[1, 1])
    sinplot(6)
    
f.tight_layout()
python
sns.axes_style()
python
sns.set_style("darkgrid", {"axes.facecolor": ".9"})
sinplot()
python
sns.set_theme()
python
sns.set_context("paper")
sinplot()
python
sns.set_context("talk")
sinplot()
python
sns.set_context("poster")
sinplot()
python
sns.set_context("notebook", font_scale=1.5, rc={"lines.linewidth": 2.5})
sinplot()