Scale and Context
The set_context() allows us to override default parameters. This affects things like the size of the labels, lines, and other elements of the plot, but not the overall style.
The context are:
- poster
- paper
- notebook
- talk
Example 1: using poster.
Python3
import seaborn as sns import matplotlib.pyplot as plt tips = sns.load_dataset( 'tips' ) sns.set_context( 'poster' , font_scale = 2 ) sns.countplot(x = 'sex' , data = tips, palette = 'coolwarm' ) |
Output:
Example 2: Using paper.
Python3
import seaborn as sns import matplotlib.pyplot as plt tips = sns.load_dataset( 'tips' ) sns.set_context( 'paper' , font_scale = 2 ) sns.countplot(x = 'sex' , data = tips, palette = 'coolwarm' ) |
Output:
Example 3: Using notebook.
Python3
import seaborn as sns import matplotlib.pyplot as plt tips = sns.load_dataset( 'tips' ) sns.set_context( 'notebook' , font_scale = 2 ) sns.countplot(x = 'sex' , data = tips, palette = 'coolwarm' ) |
Output:
Example 4: Using talk.
Python3
import seaborn as sns import matplotlib.pyplot as plt tips = sns.load_dataset( 'tips' ) sns.set_context( 'talk' , font_scale = 2 ) sns.countplot(x = 'sex' , data = tips, palette = 'coolwarm' ) |
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.
Contact Us