- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the different Figure styles in seaborn?
Seaborn is one of the powerful data visualization libraries in Python which provides various styles to customize the appearance of plots. The built-in figure styles in Seaborn helps us to customize the appearance of the plots and enhances the aesthetics of the visualization. Let's explore the different figure styles available in Seaborn one by one.
There are different Figure styles in Seaborn they are –
Default Style
Darkgrid Style:
Whitegrid Style
Dark Style
White Style
Ticks Style
When we want to apply a specific style in Seaborn, we can use the 'set_style()' function. For example, to set the darkgrid style, we would use 'seaborn.set_style("darkgrid")'. By default, the style is applied to all subsequent plots, but we can also use the 'with' statement to apply a specific style temporarily to a single plot.
Apart from the built-in figure styles, Seaborn also allows for further customization of plots using the 'set()' function. With 'set()', we can modify various aspects of the plot, such as the color palette, font scale, and grid style, to suit our preferences and requirements.
Default Style
Seaborn's default style is designed to be visually appealing and optimized for readability. It features a clean and modern look with medium gray grid lines and a white background. This style is the default style applied when creating plots with Seaborn.
Example
Following is an example where we are creating a Seaborn plot with default style –
import seaborn as sns import matplotlib.pyplot as plt # Generate some random data for plotting x = [1, 2, 3, 4, 5] y = [2, 4, 6, 8, 10] # Plot a box plot using the ticks style plt.boxplot(y) plt.title("Box Plot with default Style") plt.show()
Output
Darkgrid Style
The darkgrid style is characterized by a dark background with grid lines. It is suitable for plots that require high contrast, making it easy to focus on the data. This style is achieved by setting a dark gray background color and light gray grid lines.
Example
Following is an example –
import seaborn as sns import matplotlib.pyplot as plt # Generate some random data for plotting x = [1, 2, 3, 4, 5] y = [2, 4, 6, 8, 10] # Set the style to "darkgrid" sns.set_style("darkgrid") # Plot a line graph using the darkgrid style plt.plot(x, y) plt.title("Line Graph with Darkgrid Style") plt.show()
Output
Whitegrid Style
The whitegrid style is similar to the darkgrid style but with a white background. It combines a clean appearance with grid lines, allowing for clear visual separation between data points. This style is useful when we want to emphasize the data while maintaining a structured layout.
Example
Following is an example –
import seaborn as sns import matplotlib.pyplot as plt # Generate some random data for plotting x = [1, 2, 3, 4, 5] y = [2, 4, 6, 8, 10] # Set the style to "whitegrid" sns.set_style("whitegrid") # Plot a scatter plot using the whitegrid style plt.scatter(x, y) plt.title("Scatter Plot with Whitegrid Style") plt.show()
Output
Dark Style
The dark style provides a dark background with no grid lines. It is suitable for creating plots with a modern and minimalistic appearance. This style is achieved by setting a dark gray background color and removing the grid lines.
Example
In the following example we are trying to create Seaborn plot with dark style –
import seaborn as sns import matplotlib.pyplot as plt # Generate some random data for plotting x = [1, 2, 3, 4, 5] y = [2, 4, 6, 8, 10] # Set the style to "dark" sns.set_style("dark") # Plot a bar plot using the dark style plt.bar(x, y) plt.title("Bar Plot with Dark Style") plt.show()
Output
White Style
The white style features a white background with no grid lines. It creates a simple and clean look, suitable for plots where the focus is on the data itself. This style is achieved by setting a white background color and removing the grid lines.
Example
Let us see an example –
import seaborn as sns import matplotlib.pyplot as plt # Generate some random data for plotting x = [1, 2, 3, 4, 5] y = [2, 4, 6, 8, 10] # Set the style to "white" sns.set_style("white") # Plot a histogram using the white style plt.hist(y) plt.title("Histogram with White Style") plt.show()
Output
Ticks Style
The ticks style removes the top and right spines of the plot and only retains the ticks on the remaining spines. This style simplifies the appearance of the plot by reducing clutter while still providing necessary axis information.
Example
Following is an example –
import seaborn as sns import matplotlib.pyplot as plt # Generate some random data for plotting x = [1, 2, 3, 4, 5] y = [2, 4, 6, 8, 10] # Set the style to "ticks" sns.set_style("ticks") # Plot a box plot using the ticks style plt.boxplot(y) plt.title("Box Plot with Ticks Style") plt.show()
To Continue Learning Please Login
Login with Google