How to use set_style() method in seaborn

share link

by gayathrimohan dot icon Updated: Aug 17, 2023

technology logo
technology logo

Solution Kit Solution Kit  

Seaborn is a Python data visualization library. This library provides various styles and settings to enhance the appearance of plots. Seaborn.set_style() is a function. The Seaborn data visualization library in Python provides this function. Matplotlib is the foundation of Seaborn. It offers a high-level interface for creating attractive and informative statistical graphics. The set_style() function in Seaborn allows you to set the visual style of your plots. It provides a way to customize the aesthetics of your plots, such as background colors, grid lines, font sizes, and more. Using different style presets, you can change the appearance of your plots. You can do this to match the desired aesthetic for your analysis or presentation.  


For example, some of the available style presets in Seaborn are:  

  • "darkgrid": Displays a dark background with grid lines.  
  • "whitegrid": Displays a white background with grid lines.  
  • "dark": A dark background without grid lines.  
  • "white": A white background without grid lines.  
  • "ticks": A style with tick marks on the axes.  

Types of Seaborn styles available:  

  • Default Style: This is the default style that Seaborn uses when no specific style is set. It's clean and easy on the eyes.  
  • White Style: This style has a white background. It is suitable for situations where you want to emphasize the data. You do it without any distractions.  
  • Dark Style: This style has a dark background. It is useful for creating plots with high contrast and a modern look.  
  • Whitegrid Style: This style adds horizontal and vertical grid lines to the plots. This makes it easier to read and interpret the data.  
  • Darkgrid Style: This style adds grid lines to the dark background, enhancing readability.  
  • Ticks Style: This style removes the axes, spines, and ticks, which can be useful when focusing on the data.  
  • The despine() function, although not a style itself, removes the spines. We do this to achieve a cleaner look.  
  • Custom Styles: You can create custom styles by modifying plot elements. The elements are colors, fonts, and grid styles.  
  • Context Settings: This provides three settings that control the size of the elements. They make it easier to adapt the visualization for different use cases.  
  • Color Palettes: Seaborn offers a variety of color palettes. You can use those palettes to customize the colors of your plots.  

Some techniques available through set_style() include:  

  • "darkgrid" or "whitegrid": These styles include grid lines for better readability. "darkgrid" uses a dark background, while "whitegrid" uses a white background.  
  • "Ticks": This style adds tick marks on the axes, providing a cleaner look.  
  • "Dark" or "white": These styles set the background color to dark or white. Affecting the appearance of the plot does this.  
  • "Ticks": This style adds tick marks on the axes for a clean, minimalistic look.  
  • "Poster": This style increases the size of elements. To make the plot suitable for posters or presentations, someone does this.  
  • "Notebook": Designed for Jupyter notebooks, this style optimizes the plots for a notebook display.  
  • "Talk": Like the "notebook" style, it's suitable for presentations and emphasizes clarity.  
  • "Paper": This style ensures the plot elements are visible and distinct.  
  • "Dark" or "white": These styles set the background color to either dark or white, impacting the feel of the plot.  

Some common plot types available in Seaborn are:  

  • Bar Plot: Displays categorical data with rectangular bars. Useful for comparing values across different categories.  
  • Histogram: This shows the distribution of a numerical variable. Divide it into bins and count the frequency of data points in each bin.  
  • Line Plot: Connects data points with lines. People use it to visualize trends and relationships between two numerical variables.  
  • Scatter Plot: Represents individual data points as dots on a two-dimensional plane. Ideal for examining the relationship between two numerical variables.  
  • Box Plot: Depicts the distribution of data through quartiles. We present possible outliers and provide insights into the spread of the data.  
  • Violin Plot: Combines aspects of a box plot and a kernel density plot. We do this to display the distribution of data across different categories.  
  • Pair Plot: Displays pairwise relationships in a dataset. To accomplish this, we create scatter plots for every pair of numerical variables.  
  • Heatmap: Uses colors to visualize the relationships between two categorical variables.  
  • Joint Plot: Combines many types of plots. We do this to display the relationship between two numerical variables—also, the relationship between their distributions.  
  • Regression Plot: Combines a scatter plot with a regression line. This makes it easy to visualize the linear relationship between two variables.  


In Conclusion, Python users use the function Seaborn set_style. Seaborn plots use it to set the aesthetic style. It will allow you to customize the visual appearance of your plots, such as background color, grid lines, font sizes, and more. Different styles include "darkgrid", "whitegrid", "dark", "white", and "ticks", among others. Remember to import Seaborn (import Seaborn as sns) before using set_style().