# Seaborn Themes: set_theme, Styles, and Contexts

> Seaborn set_theme explained: darkgrid, whitegrid, dark, white, and ticks styles; paper, notebook, talk, and poster contexts; font_scale, palette, rc, and reset.

Source: https://www.pythoncharts.com/seaborn/seaborn-themes-set-theme/ | Published: 2026-11-27 | Author: Alex Scott | Category: Seaborn | Tags: seaborn, set_theme, set_style, set_context, themes, font size, rcParams, despine

`sns.set_theme()` sets the look of every chart drawn after it. `style` picks the background and grid, `context` scales text and lines, `palette` sets the colors, and `rc` overrides individual Matplotlib settings.

## Quick Example

```python
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns

# Sample data: monthly rainfall in two cities
rng = np.random.default_rng(93)
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
          "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
season = np.cos(2 * np.pi * np.arange(12) / 12)
rain = pd.DataFrame({
    "month": months * 2,
    "city": ["Coastal"] * 12 + ["Inland"] * 12,
    "mm": np.concatenate([95 + 55 * season, 55 - 25 * season]) + rng.normal(0, 6, 24),
})

sns.set_theme(
    style="ticks",            # white background with tick marks
    context="notebook",       # overall scale
    font_scale=1.1,           # extra scaling for text only
    palette=["#0369a1", "#ca8a04"],
    rc={"axes.spines.top": False, "axes.spines.right": False},
)

fig, ax = plt.subplots(figsize=(9, 4.4))
sns.barplot(data=rain, x="month", y="mm", hue="city", ax=ax)
ax.set(title="Monthly rainfall", xlabel="", ylabel="Rainfall (mm)")
ax.legend(title=None, frameon=False)
plt.show()
```

![Seaborn bar chart of monthly rainfall for a coastal and an inland city with a clean ticks style and no top or right border](https://www.pythoncharts.com/seaborn/seaborn-themes-set-theme/images/seaborn-themes-set-theme-quick-example.png)

The code targets Seaborn 0.13.

## What set_theme Changes

A theme is a set of Matplotlib `rcParams`, so it applies to plain Matplotlib and pandas charts too, and stays in effect until you change it. Calling `sns.set_theme()` with no arguments uses `style="darkgrid"`, `context="notebook"`, and `palette="deep"`. Importing Seaborn alone changes nothing. The exception is the [objects interface](https://www.pythoncharts.com/seaborn/seaborn-objects-interface/), where `so.Plot` has its own theme settings.

Call it before creating the figure. Settings such as the background color and spines are read when an Axes is created, so changing them afterward does not restyle an existing chart.

## The Five Seaborn Styles

The built-in styles are `darkgrid`, `whitegrid`, `dark`, `white`, and `ticks`. `sns.axes_style()` applies one temporarily inside a `with` block, which makes them easy to compare.

```python
inland = rain[rain["city"] == "Inland"]
styles = ["darkgrid", "whitegrid", "dark", "white", "ticks"]

sns.set_theme()
fig = plt.figure(figsize=(11, 5.6), facecolor="white")
for i, style in enumerate(styles, 1):
    with sns.axes_style(style):
        ax = fig.add_subplot(2, 3, i)
    sns.lineplot(data=inland, x="month", y="mm", marker="o", color="#0369a1", ax=ax)
    ax.set(title=f'style="{style}"', xlabel="", ylabel="", xticks=range(0, 12, 3))
fig.tight_layout()
plt.show()
```

![The same rainfall line in darkgrid, whitegrid, dark, white, and ticks styles](https://www.pythoncharts.com/seaborn/seaborn-themes-set-theme/images/seaborn-themes-set-theme-styles.png)

| Style | Background | Grid | Good for |
|---|---|---|---|
| `darkgrid` | Gray | White | Exploring data; the grid stays behind the data |
| `whitegrid` | White | Gray | Reports where readers estimate values |
| `dark` | Gray | None | Images and heatmaps |
| `white` | White | None | Clean figures with labeled values |
| `ticks` | White | None | Publications; adds tick marks |

## Remove the Top and Right Borders with despine

`sns.despine()` hides the top and right spines of the current figure. Call it after plotting. It suits `white` and `ticks`.

```python
sns.set_theme(style="ticks")
fig, ax = plt.subplots(figsize=(8, 4))
sns.scatterplot(x=season, y=rain["mm"].iloc[:12], s=90, color="#0369a1", ax=ax)
ax.set(xlabel="Winter index", ylabel="Coastal rainfall (mm)")
sns.despine(offset=8, trim=True)
plt.show()
```

![Scatter plot with only left and bottom axis lines, offset from the data and trimmed to the outer ticks](https://www.pythoncharts.com/seaborn/seaborn-themes-set-theme/images/seaborn-themes-set-theme-despine.png)

`offset` moves the remaining spines away from the data, and `trim=True` ends them at the outermost ticks. Pass `left=True` to remove the left spine as well.

## Contexts: paper, notebook, talk, and poster

The context scales fonts, line widths, and marker sizes together, without touching colors or the background.

| Context | Scale | Label font size |
|---|---|---|
| `paper` | 0.8× | 9.6 |
| `notebook` (default) | 1× | 12 |
| `talk` | 1.5× | 18 |
| `poster` | 2× | 24 |

The figure size does not change, so larger contexts take up more of the same canvas. The four panels here are the same size:

```python
sns.set_theme(style="whitegrid")
fig = plt.figure(figsize=(11, 6.5))
for i, context in enumerate(["paper", "notebook", "talk", "poster"], 1):
    with sns.plotting_context(context):
        ax = fig.add_subplot(2, 2, i)
        sns.lineplot(data=inland, x="month", y="mm", marker="o", color="#0369a1", ax=ax)
        ax.set(title=f'context="{context}"', xlabel="", ylabel="mm", xticks=range(0, 12, 3))
fig.tight_layout()
plt.show()
```

![Four copies of one chart where text, lines, and markers grow from paper to poster context](https://www.pythoncharts.com/seaborn/seaborn-themes-set-theme/images/seaborn-themes-set-theme-contexts.png)

Increase `figsize` along with the context when preparing slides.

## Change Font Size with font_scale

`font_scale` multiplies the text sizes only, on top of the context.

```python
sns.set_theme(style="whitegrid", font_scale=1.6)
fig, ax = plt.subplots(figsize=(8, 4))
sns.barplot(data=inland, x="month", y="mm", color="#ca8a04", ax=ax)
ax.set(title="Inland rainfall", xlabel="", ylabel="mm")
plt.show()
```

![Bar chart of inland rainfall with enlarged title, axis label, and tick labels](https://www.pythoncharts.com/seaborn/seaborn-themes-set-theme/images/seaborn-themes-set-theme-font-scale.png)

To size one element, set its `rcParams` key through `rc`, as shown next.

## Override Individual Settings with rc

`rc` takes any Matplotlib parameter and is applied last, so it wins over the style and context.

```python
sns.set_theme(
    style="whitegrid",
    rc={
        "axes.titlesize": 17,
        "axes.titleweight": "bold",
        "axes.titlelocation": "left",
        "grid.linestyle": ":",
        "grid.color": "#94a3b8",
        "axes.spines.left": False,
        "axes.spines.right": False,
        "axes.spines.top": False,
    },
)
fig, ax = plt.subplots(figsize=(8, 4))
sns.lineplot(data=rain, x="month", y="mm", hue="city",
             palette=["#0369a1", "#ca8a04"], linewidth=2.5, ax=ax)
ax.set(title="Rainfall through the year", xlabel="", ylabel="mm")
plt.show()
```

![Line chart with a bold left-aligned title, dotted gray grid, and only a bottom border](https://www.pythoncharts.com/seaborn/seaborn-themes-set-theme/images/seaborn-themes-set-theme-rc.png)

`print(sns.axes_style())` and `print(sns.plotting_context())` list the current style and context values. For more parameters and style files, see [Matplotlib rcParams and global defaults](https://www.pythoncharts.com/matplotlib/matplotlib-rcparams-defaults/).

## Set the Color Palette

`palette` accepts a Seaborn palette name, a Matplotlib colormap name, or a list of colors. The variants of the default palette are `deep`, `muted`, `pastel`, `bright`, `dark`, and `colorblind`.

```python
sns.set_theme(style="white", palette="colorblind")
names = ["deep", "muted", "pastel", "bright", "dark", "colorblind"]

fig, axes = plt.subplots(len(names), 1, figsize=(8, 4.2))
for ax, name in zip(axes, names):
    for i, color in enumerate(sns.color_palette(name)):
        ax.add_patch(plt.Rectangle((i, 0), 0.95, 1, color=color))
    ax.set(xlim=(0, 10), ylim=(0, 1))
    ax.set_ylabel(name, rotation=0, ha="right", va="center")
    ax.set(xticks=[], yticks=[])
    sns.despine(ax=ax, left=True, bottom=True)
plt.show()
```

![Color swatches for the deep, muted, pastel, bright, dark, and colorblind palettes](https://www.pythoncharts.com/seaborn/seaborn-themes-set-theme/images/seaborn-themes-set-theme-palettes.png)

See [custom color palettes in Seaborn](https://www.pythoncharts.com/seaborn/seaborn-custom-color-palettes/) for building your own.

## Apply a Theme to One Chart Only

`axes_style()`, `plotting_context()`, and `color_palette()` all work as context managers. Settings return to their previous values when the block ends. Create the figure inside the block.

```python
sns.set_theme(style="white")

with sns.axes_style("darkgrid"), sns.plotting_context("talk"), sns.color_palette("Set2"):
    fig, ax = plt.subplots(figsize=(8, 4))
    sns.barplot(data=rain, x="month", y="mm", hue="city", ax=ax)
    ax.set(xlabel="", ylabel="mm", ylim=(0, 210))
    ax.legend(ncols=2, loc="upper center")
    plt.show()
```

![Grouped bar chart drawn with a temporary dark grid style, talk context, and Set2 palette](https://www.pythoncharts.com/seaborn/seaborn-themes-set-theme/images/seaborn-themes-set-theme-temporary.png)

## Reset to the Defaults

```python
sns.reset_defaults()  # Matplotlib's built-in defaults
sns.reset_orig()      # your settings from before Seaborn changed them
```

The two differ only if you have a `matplotlibrc` file or a style sheet that was active when Seaborn was imported. `reset_orig()` restores it.

## set_theme vs set_style vs set_context

| Function | Changes | Use it when |
|---|---|---|
| `set_theme()` | Style, context, palette, font, and any `rc` | Setting up a script or notebook |
| `set_style()` | Background, grid, spines, ticks, colors of axes and text | Changing only the style |
| `set_context()` | Font, line, and marker sizes | Switching from notebook to slides |
| `set_palette()` | Color cycle | Changing only the colors |
| `axes_style()`, `plotting_context()` | Same as the setters, temporarily | Styling one figure |

Two details cause confusion:

- Each setter's `rc` argument only accepts its own keys. `sns.set_style("white", rc={"axes.titlesize": 20})` is silently ignored because title size belongs to the context. `set_theme(rc=...)` accepts everything.
- Calling `set_theme()` again resets the arguments you leave out to their defaults, so `sns.set_theme(font_scale=1.4)` after `sns.set_theme(style="ticks")` goes back to `darkgrid`.

`sns.set()` is an older alias for `set_theme()`.

## Similar Topics

- [How to Make Custom Color Palettes in Seaborn](https://www.pythoncharts.com/seaborn/seaborn-custom-color-palettes/)
- [How to Save Seaborn Figures in High Resolution](https://www.pythoncharts.com/seaborn/seaborn-save-high-resolution-figures/)
- [Matplotlib rcParams and Global Defaults](https://www.pythoncharts.com/matplotlib/matplotlib-rcparams-defaults/)
