- Seaborn Tutorial
- Seaborn - Home
- Seaborn - Introduction
- Seaborn - Environment Setup
- Importing Datasets and Libraries
- Seaborn - Figure Aesthetic
- Seaborn- Color Palette
- Seaborn - Histogram
- Seaborn - Kernel Density Estimates
- Visualizing Pairwise Relationship
- Seaborn - Plotting Categorical Data
- Distribution of Observations
- Seaborn - Statistical Estimation
- Seaborn - Plotting Wide Form Data
- Multi Panel Categorical Plots
- Seaborn - Linear Relationships
- Seaborn - Facet Grid
- Seaborn - Pair Grid
- Function Reference
- Seaborn - Function Reference
- Seaborn Useful Resources
- Seaborn - Quick Guide
- Seaborn - Useful Resources
- Seaborn - Discussion
Seaborn.set_style() method
The Seaborn.set_style() method sets the parameters that control the general style of the plots. This method works closely with the seaborn.axes_style() method as this also checks whether the grid is enabled by default and uses its style parameters control various properties like background color etc.
Setting these parameters to control the general style of the plot can be accomplished by the matplotlib rcParams system.
Syntax
Following is the syntax of the seaborn.set_style() method −
seaborn.set_style(style=None, rc=None)
Parameters
Following are the parameters of seaborn.set_style() method −
S.No | Parameter and Description |
---|---|
1 | Style Takes values, None, dict, or one of {darkgrid, whitegrid, dark, white, ticks} and determines a dictionary of parameters or the name of a preconfigured style. |
2 | Rc Takes rcdict as value and is an optional parameter that performs Parameter mappings to override the values in the preset seaborn style dictionaries. This only updates parameter that are considered part of the style definition. |
Now we will move onto understanding the method and using it in examples.
Example 1
The style is set to “whitegrid” and a scatter plot is drawn with a list of values. The plot obtained is shown.
import seaborn as sns import matplotlib.pyplot as plt tips=sns.load_dataset("tips") tips.head() sns.set_style("whitegrid") sns.scatterplot(x=["A", "B", "C"], y=[10, 30, 23]) plt.show()
Output
The graph is as follows −
Example 2
We will see another style in this example. The dark is a style that can be set and the plot obtained will be like the one shown below.
import seaborn as sns import matplotlib.pyplot as plt tips=sns.load_dataset("tips") tips.head() sns.set_style("dark") sns.scatterplot(x=["A", "B", "C"], y=[10, 30, 23]) plt.show()
Output
the output obtained is,
Example 3
In this example, we will see how the grid color and grid line style can be changed when setting the style. You have to initialize them like shown below and the graph obtained will change as shown.
import seaborn as sns import matplotlib.pyplot as plt tips=sns.load_dataset("tips") tips.head() sns.set_style("darkgrid", {"grid.color": ".2", "grid.linestyle": ":"}) sns.lineplot(x=["man", "women", "child"], y=[45, 50, 20]) plt.show()
Output
The output obtained is as follows −
To Continue Learning Please Login
Login with Google