By default, plots made with seaborn have a white background. However, it is possible to change its background color passing a dictionary to the rc
argument of the set_style
function, as shown below.
import numpy as np
import seaborn as sns
# Data simulation
rng = np.random.RandomState(10)
x = rng.normal(0, 1, size = 100)
# Set the background color
sns.set_style(rc = {'axes.facecolor': 'lightsteelblue'})
# Plot
sns.histplot(x = x)
An alternative is setting a theme with axes_style
, with set_style
or with set_style
to modify the global parameters. In this example we are setting the "darkgrid"
theme.
import numpy as np
import seaborn as sns
# Data simulation
rng = np.random.RandomState(10)
x = rng.normal(0, 1, size = 100)
# Set the style
sns.set_style("darkgrid")
# Plot
sns.histplot(x = x)
Use the following color picker to choose a background color or press the “Generate random” button to select a random color.
See also