The Wayback Machine - https://web.archive.org/web/20241004181113/https://www.geeksforgeeks.org/seaborn-distribution-plots/
Open In App

Seaborn | Distribution Plots

Last Updated : 25 Aug, 2022
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Seaborn is a Python data visualization library based on Matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. This article deals with the distribution plots in seaborn which is used for examining univariate and bivariate distributions. In this article we will be discussing 4 types of distribution plots namely:

  1. joinplot
  2. distplot
  3. pairplot
  4. rugplot

Besides providing different kinds of visualization plots, seaborn also contains some built-in datasets. We will be using the tips dataset in this article. The “tips” dataset contains information about people who probably had food at a restaurant and whether or not they left a tip, their age, gender and so on. Lets have a look at it. Code : 

Python3




# import the necessary libraries
import seaborn as sns
import matplotlib.pyplot as plt % matplotlib inline
 
# to ignore the warnings
from warnings import filterwarnings
 
# load the dataset
df = sns.load_dataset('tips')
 
# the first five entries of the dataset
df.head()


Now, lets proceed onto the plots.  

Displot

It is used basically for univariant set of observations and visualizes it through a histogram i.e. only one observation and hence we choose one particular column of the dataset. Syntax:

distplot(a[, bins, hist, kde, rug, fit, ...])

Example: 

Python3




# set the background style of the plot
sns.set_style('whitegrid')
sns.distplot(df['total_bill'], kde = False, color ='red', bins = 30)


Output: Explanation:

  • KDE stands for Kernel Density Estimation and that is another kind of the plot in seaborn.
  • bins is used to set the number of bins you want in your plot and it actually depends on your dataset.
  • color is used to specify the color of the plot

Now looking at this we can say that most of the total bill given lies between 10 and 20.

Joinplot

It is used to draw a plot of two variables with bivariate and univariate graphs. It basically combines two different plots. Syntax:

jointplot(x, y[, data, kind, stat_func, ...])    

Example: 

Python3




sns.jointplot(x ='total_bill', y ='tip', data = df)


Output:  

Python3




sns.jointplot(x ='total_bill', y ='tip', data = df, kind ='kde')
# KDE shows the density where the points match up the most


Explanation:

  • kind is a variable that helps us play around with the fact as to how do you want to visualise the data.It helps to see whats going inside the joinplot. The default is scatter and can be hex, reg(regression) or kde.
  • x and y are two strings that are the column names and the data that column contains is used by specifying the data parameter.
  • here we can see tips on the y axis and total bill on the x axis as well as a linear relationship between the two that suggests that the total bill increases with the tips.
    • hue sets up the categorical separation between the entries if the dataset.
    • palette is used for designing the plots.


Similar Reads

Surface plots and Contour plots in Python
Matplotlib was introduced keeping in mind, only two-dimensional plotting. But at the time when the release of 1.0 occurred, the 3d utilities were developed upon the 2d and thus, we have 3d implementation of data available today! The 3d plots are enabled by importing the mplot3d toolkit. In this article, we will discuss the surface plots and contour
4 min read
ML | Matrix plots in Seaborn
Seaborn is a wonderful visualization library provided by python. It has several kinds of plots through which it provides the amazing visualization capabilities. Some of them include count plot, scatter plot, pair plots, regression plots, matrix plots and much more. This article deals with the matrix plots in seaborn. Example 1: Heatmaps Heatmap is
4 min read
Seaborn | Regression Plots
The regression plots in seaborn are primarily intended to add a visual guide that helps to emphasize patterns in a dataset during exploratory data analyses. Regression plots as the name suggests creates a regression line between 2 parameters and helps to visualize their linear relationships. This article deals with those kinds of plots in seaborn a
4 min read
Seaborn | Categorical Plots
Plots are basically used for visualizing the relationship between variables. Those variables can be either be completely numerical or a category like a group, class or division. This article deals with categorical variables and how they can be visualized using the Seaborn library provided by Python. Seaborn besides being a statistical plotting libr
5 min read
Relational plots in Seaborn - Part I
Relational plots are used for visualizing the statistical relationship between the data points. Visualization is necessary because it allows the human to see trends and patterns in the data. The process of understanding how the variables in the dataset relate each other and their relationships are termed as Statistical analysis. Seaborn, unlike to
4 min read
Relational plots in Seaborn - Part II
Prerequisite: Relational Plots in Seaborn - Part IIn the previous part of this article, we learnt about the relplot(). Now, we will be reading about the other two relational plots, namely scatterplot() and lineplot() provided in seaborn library. Both these plots can also be drawn with the help of kind parameter in relplot(). Basically relplot(), by
6 min read
Visualising ML DataSet Through Seaborn Plots and Matplotlib
Working on data can sometimes be a bit boring. Transforming a raw data into an understandable format is one of the most essential part of the whole process, then why to just stick around on numbers, when we can visualize our data into mind-blowing graphs which are up for grabs in python. This article will focus on exploring plots which could make y
7 min read
Dex scatter Plots
The scatter plot is used to determine whether two variables have some correlation with each other. This plot uses dots to represent different data points in the dataset. The dex (design and Experiment) scatter plot is a technique used in the analysis of the process. Dex Scatter plot is used to answer three important questions: What data points are
3 min read
Contour plots
A contour plot is a graphical method to visualize the 3-D surface by plotting constant Z slices called contours in a 2-D format. The contour plot is an alternative to a 3-D surface plot The contour plot is formed by: Vertical axis: Independent variable 2Horizontal axis: Independent variable 1Lines: iso-response values, can be calculated with the he
4 min read
Lag Plots
A lag plot is a special type of scatter plot in which the X-axis represents the dataset with some time units behind or ahead as compared to the Y-axis. The difference between these time units is called lag or lagged and it is represented by k. The lag plot contains the following axes: Vertical axis: Yi for all iHorizontal axis: Yi-k for all i, wher
3 min read
8 Types of Plots for Time Series Analysis using Python
Time series data Time series data is a collection of observations chronologically arranged at regular time intervals. Each observation corresponds to a specific time point, and the data can be recorded at various frequencies (e.g., daily, monthly, yearly). This type of data is very essential in many fields, including finance, economics, climate sci
10 min read
Quantile Quantile plots
The quantile-quantile( q-q plot) plot is a graphical method for determining if a dataset follows a certain probability distribution or whether two samples of data came from the same population or not. Q-Q plots are particularly useful for assessing whether a dataset is normally distributed or if it follows some other known distribution. They are co
8 min read
Pair plots using Scatter matrix in Pandas
Checking for collinearity among attributes of a dataset, is one of the most important steps in data preprocessing. A good way to understand the correlation among the features, is to create scatter plots for each pair of attributes. Pandas has a function scatter_matrix(), for this purpose. scatter_matrix() can be used to easily generate a group of s
2 min read
Residual plots for Nonlinear Regression
Nonlinear regression is a form of regression analysis where data is fit to a model expressed as a nonlinear function. Unlike linear regression, where the relationship between the independent and dependent variables is linear, nonlinear regression involves more complex relationships. One of the critical tools in evaluating the fit of a nonlinear reg
4 min read
How to Generate Feature Importance Plots from Scikit-Learn?
Understanding which factors affect predictions in machine learning models is vital for making them more accurate and reliable. Feature importance plots are tools that help us see and rank these factors visually, which makes it simpler to understand and improve our models. Here we create these plots using Python's Scikit-Learn library it help us to
3 min read
Plotting graph using Seaborn | Python
This article will introduce you to graphing in Python with Seaborn, which is the most popular statistical visualization library in Python. Installation: The easiest way to install seaborn is to use pip. Type following command in terminal: pip install seaborn OR, you can download it from here and install it manually. Plotting categorical scatter plo
8 min read
Python Seaborn - Catplot
Seaborn is a Python data visualization library based on matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. Seaborn helps resolve the two major problems faced by Matplotlib; the problems are? Default Matplotlib parametersWorking with data frames As Seaborn compliments and extends Matplotlib, t
5 min read
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. 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
4 min read
Grid Plot in Python using Seaborn
Grids are general types of plots that allow you to map plot types to grid rows and columns, which helps you to create similar character-separated plots. In this article, we will be using two different data sets (Iris and Tips) for demonstrating grid plots Using Iris Dataset We are going to use the Iris dataset which is a very famous dataset availab
4 min read
Seaborn Kdeplot – A Comprehensive Guide
Kernel Density Estimate (KDE) Plot is a powerful tool for estimating the probability density function of continuous or non-parametric data. KDE plot is implemented through the kdeplot function in Seaborn. This article explores the syntax and usage of kdeplot in Python, focusing on one-dimensional and bivariate scenarios for efficient data visualiza
4 min read
Plotting graph For IRIS Dataset Using Seaborn And Matplotlib
Matplotlib.pyplot library is most commonly used in Python in the field of machine learning. It helps in plotting the graph of large dataset. Not only this also helps in classifying different dataset. It can plot graph both in 2d and 3d format. It has a feature of legend, label, grid, graph shape, grid and many more that make it easier to understand
2 min read
seaborn.crayon_palette Method()
Seaborn is a Python data visualization library based on Matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. There is just something extraordinary about a well-designed visualization. In this article we will learn about the Python seaborn.crayon_palette Method(). What is seaborn.crayon_palette(
2 min read
Python | Titanic Data EDA using Seaborn
What is EDA? Exploratory Data Analysis (EDA) is a method used to analyze and summarize datasets. Majority of the EDA techniques involve the use of graphs. Titanic Dataset - It is one of the most popular datasets used for understanding machine learning basics. It contains information of all the passengers aboard the RMS Titanic, which unfortunately
5 min read
Multi-plot grid in Seaborn
Prerequisites: Matplotlib, Seaborn In this article, we are going to see multi-dimensional plot data, It is a useful approach to draw multiple instances of the same plot on different subsets of your dataset. It allows a viewer to quickly extract a large amount of information about a complex dataset. In Seaborn, we will plot multiple graphs in a sing
7 min read
Seaborn - Color Palette
In this article, We are going to see seaborn color_palette(), which can be used for coloring the plot. Using the palette we can generate the point with different colors . In this below example we can see the palette can be responsible for generating the different colormap values. Syntax: seaborn.color_palette( palette=None , n_colors=None , desat=N
4 min read
Map Data to a Normal Distribution in Scikit Learn
A Normal Distribution, also known as a Gaussian distribution, is a continuous probability distribution that is symmetrical around its mean. It is defined by its norm, which is the center of the distribution, and its standard deviation, which is a measure of the spread of the distribution. The normal distribution is often used to model continuous an
5 min read
NLP | Storing Conditional Frequency Distribution in Redis
The nltk.probability.ConditionalFreqDist class is a container for FreqDist instances, with one FreqDist per condition. It is used to count frequencies that are dependent on another condition, such as another word or a class label. It is being used here to create an API-compatible class on top of Redis using the RedisHashFreqDist . In the code given
2 min read
NLP | Storing Frequency Distribution in Redis
The nltk.probability.FreqDist class is used in many classes throughout NLTK for storing and managing frequency distributions. It's quite useful, but it's all in-memory, and doesn't provide a way to persist the data. A single FreqDist is also not accessible to multiple processes. All that can be changed by building a FreqDist on top of Redis. What i
3 min read
Inverse Gamma Distribution in Python
Inverse Gamma distribution is a continuous probability distribution with two parameters on the positive real line. It is the reciprocate distribution of a variable distributed according to the gamma distribution. It is very useful in Bayesian statistics as the marginal distribution for the unknown variance of a normal distribution. It is used for c
2 min read
Python - Student’s t Distribution in Statistics
We know the mathematics behind t-distribution. However, we can also use Python to implement t-distribution on a dataset. Python provides a unique package scipy for various statical techniques and methods. We will use this package for t-distribution implementation. prerequisite: t-distribution What is t-Distribution The t-distribution, also known as
5 min read
Article Tags :
Practice Tags :