seaborn.objects.Plot.theme#

Plot.theme(*args)#

Control the default appearance of elements in the plot.

Note

The API for customizing plot appearance is not yet finalized. Currently, the only valid argument is a dict of matplotlib rc parameters. (This dict must be passed as a positional argument.)

It is likely that this method will be enhanced in future releases.

Matplotlib rc parameters are documented on the following page: https://matplotlib.org/stable/tutorials/introductory/customizing.html

Examples

The default theme uses the same parameters as seaborn.set_theme() with no additional arguments:

p = (
    so.Plot(anscombe, "x", "y")
    .facet("dataset", wrap=2)
    .add(so.Line(), so.PolyFit(order=1))
    .add(so.Dot())
)
p
../_images/objects.Plot.theme_1_0.png

Pass a dictionary of rc parameters to change the appearance of the plot:

p.theme({"axes.facecolor": "w", "axes.edgecolor": "C0"})
../_images/objects.Plot.theme_3_0.png

Many (though not all) mark properties will reflect theme parameters by default:

p.theme({"lines.linewidth": 4})
../_images/objects.Plot.theme_5_0.png

Apply seaborn styles by passing in the output of the style functions:

from seaborn import axes_style
p.theme({**axes_style("ticks")})
../_images/objects.Plot.theme_7_0.png

Or apply styles that ship with matplotlib:

from matplotlib import style
p.theme({**style.library["fivethirtyeight"]})
../_images/objects.Plot.theme_9_0.png