Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Seaborn · Function

set_theme

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.

How it works

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.

Syntax

seaborn.set_theme(*, context='notebook', style='darkgrid', palette='deep', font='sans-serif', font_scale=1, color_codes=True, rc=None)

Parameters

NameTypeDescription
contextstring or dictPlotting context preset or parameter dictionary.
stylestring or dictAxes style preset or parameter dictionary.
palettestring or sequenceNamed palette or color sequence.
fontstringFont family name.
font_scalefloatScale factor for plot font and element sizes.
color_codesboolWhether to alter Matplotlib color shorthand meanings.
rcdictMatplotlib rc parameter overrides or additional rc parameters.

Key points

  • The function establishes the appearance used by both Seaborn and Matplotlib plots.
  • Its default context is notebook, its default axes style is darkgrid, and its default palette is deep.
  • The defaults use a sans-serif font, unit font scaling, enabled color codes, and no extra rc dictionary.
  • Theme components are independent, allowing focused changes such as style or palette without changing every setting.
  • The rc argument can override Seaborn parameters or define extra Matplotlib rc settings.
  • A no-argument call activates the default Seaborn theme.

Common mistakes

  • The call affects global plotting defaults, including plots created directly with Matplotlib.
  • Use None for an individual theme group when you want to leave its current settings unchanged.
  • Do not assume the changes are limited to Seaborn-generated figures.

Example: Customize a plot theme

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.

When to use it

Set a project-wide default theme

A notebook or application needs consistent styling across all later charts.

Combine an axes style with a palette

A chart needs a particular grid treatment and coordinated colors.

Scale plot typography

A presentation requires larger labels and text.

Apply custom rc parameters

A plot needs Matplotlib settings outside Seaborn's presets.

Interview questions

QWhat does set_theme change?

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.

QWhich aspects can set_theme configure?

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.

QHow do you apply the default theme and customize Matplotlib settings?

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_style
  • set_style
  • plotting_context
  • set_context
  • set_color_codes
  • reset_defaults
  • set

Source: seaborn.set_theme — seaborn 0.13.2 documentation. Checked 2026-10-15.