seaborn.
set_context
(context=None, font_scale=1, rc=None)¶Set the parameters that control the scaling of plot elements.
This affects things like the size of the labels, lines, and other elements of the plot, but not the overall style. This is accomplished using the matplotlib rcParams system.
The base context is “notebook”, and the other contexts are “paper”, “talk”, and “poster”, which are version of the notebook parameters scaled by different values. Font elements can also be scaled independently of (but relative to) the other values.
See plotting_context()
to get the parameter values.
A dictionary of parameters or the name of a preconfigured set.
Separate scaling factor to independently scale the size of the font elements.
Parameter mappings to override the values in the preset seaborn context dictionaries. This only updates parameters that are considered part of the context definition.
Examples
Call the function with the name of a context to set the default for all plots:
sns.set_context("notebook")
sns.lineplot(x=[0, 1, 2], y=[1, 3, 2])
You can independently scale the font elements relative to the current context:
sns.set_context("notebook", font_scale=1.25)
sns.lineplot(x=[0, 1, 2], y=[1, 3, 2])
It is also possible to override some of the parameters with specific values:
sns.set_context("notebook", rc={"lines.linewidth": 3})
sns.lineplot(x=[0, 1, 2], y=[1, 3, 2])