Seaborn Figure Styles

This affects things like the color of the axes, whether a grid is enabled by default, and other aesthetic elements.

The ways of styling themes are as follows:

  • white
  • dark
  • whitegrid
  • darkgrid
  • ticks

Set the background to be white:

Given style with the help of countplot and the dataset is present in seaborn by default. load_dataset() function is used to load the dataset. set_style() function is used for plot styling.

Python3




import seaborn as sns
import matplotlib.pyplot as plt
 
# load the tips dataset present by default in seaborn
tips = sns.load_dataset('tips')
sns.set_style('white')
 
# make a countplot
sns.countplot(x ='sex', data = tips)


Output: 
 

 

Set the background to ticks:

Ticks appear on the sides of the plot on setting it as set_style(‘ticks’). palette attribute is used to set the color of the bars. It helps to distinguish between chunks of data.

Python3




import seaborn as sns
import matplotlib.pyplot as plt
  
tips = sns.load_dataset('tips')
sns.set_style('ticks')
sns.countplot(x ='sex', data = tips, palette = 'deep')


Output:

Set the background to be darkgrid:

Darkgrid appear on the sides of the plot on setting it as set_style(‘darkgrid’). palette attribute is used to set the color of the bars. It helps to distinguish between chunks of data.

Python3




import seaborn as sns
import matplotlib.pyplot as plt
 
# load the tips dataset present by default in seaborn
tips = sns.load_dataset('tips')
sns.set_style('darkgrid')
 
# make a countplot
sns.countplot(x ='sex', data = tips)


Output:

Set the background to be Whitegrid:

Whitegrid appears on the sides of the plot on setting it as set_style(‘whitegrid’). palette attribute is used to set the color of the bars. It helps to distinguish between chunks of data.

Python3




import seaborn as sns
import matplotlib.pyplot as plt
 
# load the tips dataset present by default in seaborn
tips = sns.load_dataset('tips')
sns.set_style('whitegrid')
 
# make a countplot
sns.countplot(x ='sex', data = tips)


Output:

Seaborn | Style And Color

Seaborn is a statistical plotting library in python. It has beautiful default styles. This article deals with the ways of styling the different kinds of plots in seaborn. 

Similar Reads

Seaborn Figure Styles

This affects things like the color of the axes, whether a grid is enabled by default, and other aesthetic elements....

Removing Axes Spines

...

Size and aspect

...

Scale and Context

...

Contact Us