Set a project-wide default theme
A notebook or application needs consistent styling across all later charts.
Seaborn · Function
Configures Seaborn's global visual theme for subsequent Seaborn and Matplotlib plots. It independently controls context, axes style, palette, typography, color shorthand behavior, and Matplotlib rc overrides.
set_theme updates Seaborn's global plotting configuration through Matplotlib's rcParams system. It combines context scaling, axes style, palette, font settings, color shorthand handling, and optional rc overrides, so subsequent Seaborn and Matplotlib plots use the selected appearance.
seaborn.set_theme(*, context='notebook', style='darkgrid', palette='deep', font='sans-serif', font_scale=1, color_codes=True, rc=None)| Name | Type | Description |
|---|---|---|
context | string or dict | Plotting context preset or parameter dictionary. |
style | string or dict | Axes style preset or parameter dictionary. |
palette | string or sequence | Named palette or color sequence. |
font | string | Font family name. |
font_scale | float | Scale factor for plot font and element sizes. |
color_codes | bool | Whether to alter Matplotlib color shorthand meanings. |
rc | dict | Matplotlib rc parameter overrides or additional rc parameters. |
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_theme(style="whitegrid", palette="pastel", font_scale=1.1,
rc={"axes.spines.right": False})
sns.barplot(x=["A", "B", "C"], y=[1, 3, 2])
plt.show()Applies a white-grid theme, pastel colors, larger text, and hides the right axis spine before drawing a bar plot.
A notebook or application needs consistent styling across all later charts.
A chart needs a particular grid treatment and coordinated colors.
A presentation requires larger labels and text.
A plot needs Matplotlib settings outside Seaborn's presets.
set_theme configures the visual theme for Seaborn and Matplotlib plots. It writes the selected settings into Matplotlib's global rcParams, so later plots inherit them.
Follow-up: How would you avoid changing a particular theme component? Pass None for that component, which preserves its current values.
The function accepts independent controls for context, style, palette, font, font scaling, color-code behavior, and rc overrides. This lets you combine a preset with targeted customization.
Follow-up: How can you add a setting not covered by a Seaborn theme? Supply it through the rc dictionary, such as an axes spine setting.
Calling set_theme with no arguments activates Seaborn's default theme. Passing rc allows additional Matplotlib rc parameters or overrides to be applied at the same time.
Follow-up: What is the preferred API alias? The API reference identifies set as an alias, while set_theme is the preferred interface.
axes_styleset_styleplotting_contextset_contextset_color_codesreset_defaultsset