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
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()

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, 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.
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()

| 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.
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()

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:
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()

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.
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()

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.
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()

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.
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.
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()

See custom color palettes in Seaborn 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.
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()

Reset to the Defaults
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
rcargument 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, sosns.set_theme(font_scale=1.4)aftersns.set_theme(style="ticks")goes back todarkgrid.
sns.set() is an older alias for set_theme().