Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Pandas
  • Matplotlib
  • Plotly
  • Altair
  • Bokeh
  • Data Analysis
  • R
  • Machine Learning Math
  • Machin Learning
  • Deep Learning
  • Deep Learning Projects
  • NLP
  • Computer vision
  • Data science
  • Deep learning interview question
  • Machin Learning Interview question
Open In App
Next Article:
How To Make Simple Facet Plots with Seaborn Catplot in Python?
Next article icon

How to Make ECDF Plot with Seaborn in Python?

Last Updated : 27 Jan, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

Prerequisites:  Seaborn

In this article, we are going to make the ECDF plot with Seaborn Library.

ECDF Plot

  • ECDF stands for Empirical Commutative Distribution. It is more likely to use instead of the histogram for visualizing the data because the ECDF plot visualizes each and every data point of the dataset directly, which makes it easy for the user to interact with the plot.
  • This plot contains more information because it has no bin size setting, which means it doesn’t have any smoothing parameters.
  • Since its curves are monotonically increasing, so it is well suited for comparing multiple distributions at the same time.
  • In an ECDF plot, the x-axis corresponds to the range of values for the variable whereas the y-axis corresponds to the proportion of data points that are less than or equal to the corresponding value of the x-axis.
  • We can make the ECDF plot directly by using ecdfplot() function, or we can also make the plot by using displot() function with the new Seaborn version.

Installation:

To install the Seaborn library, write the following command in your command prompt.

pip install seaborn

This ECDF plot and displot() function is available only in the new version of Seaborn that is version 0.11.0 or above. If already install Seaborn upgrade it by writing the following command.

pip install seaborn==0.11.0

For a better understanding of the ECDF plot. Let’s plot and do some examples using the datasets.

Step-by-Step Approach:

  • Import the seaborn library.
  • Create or load the dataset from the seaborn library.
  • Select the column for which you are plotting the ECDF plot.
  • For plotting the ECDF plot there are two ways are as follows:
  • The first way is to use ecdfplot() function to directly plot the ECDF plot and in the function pass you data and column name on which you are plotting.

Syntax:

seaborn.ecdfplot(data=’dataframe’,x=’column_name’,y=’column_name’, hue=’color_column’)

  • The second way is to use displot() function and pass your data and column on which you are making the plot and pass the parameter of displot kind=’ecdf’.

Syntax:

seaborn.displot(data=’dataframe’, x=’column_name’,y=’column_name’ kind=’type_of_plot’,hue=’color_column’, palette=’color’

The below table shows the list of parameters used in this article.

ParameterDescription
dataData frame or numpy.ndarray
xKey vectors in data or column name on which plot is made.
yKey vectors in data or column name on which plot is made.
hueTo determine the color of the plot variable.
palette

This parameter is used to choose color when mapping the hue. 

It can be string, list, dict.

kindIt is the parameter of displot(), used to give the kind of plot we want.

Method 1: Using ecdfplot() method

In this method, we are using ‘exercise’ data provided by seaborn.

Python

# importing library
import seaborn as sns
 
# loading exercise dataset provided by seaborn
excr = sns.load_dataset('exercise')
 
# printing the dataset
print(excr)
                      
                       

Output:

Example 1: Making ECDF plot by using exercise dataset provided by seaborn.

Python

# importing libraries
import seaborn as sns
import matplotlib.pyplot as plt
 
# loading exercise dataset provided by seaborn
excr = sns.load_dataset('exercise')
 
# making ECDF plot
sns.ecdfplot(data=excr,x='pulse')
 
# visualizing the plot using matplotlib.pyplot
# show() function
plt.show()
                      
                       

Output:

Example 2: Making ECDF plot by interchanging the plot axis.

Python

# importing libraries
import seaborn as sns
import matplotlib.pyplot as plt
 
# loading exercise dataset provided by seaborn
excr = sns.load_dataset('exercise')
 
# making ECDF plot
sns.ecdfplot(data=excr,y='pulse')
 
# visualizing the plot using matplotlib.pyplot
# show() function
plt.show()
                      
                       

Output:

Example 3: Making ECDF plot when we have multiple distributions.

Python

# importing libraries
import seaborn as sns
import matplotlib.pyplot as plt
 
# loading exercise dataset provided by seaborn
excr = sns.load_dataset('exercise')
 
# making ECDF plot when we have multiple
# distributions
sns.ecdfplot(data=excr, x='pulse', hue='kind')
 
# visualizing the plot using matplotlib.pyplot
# show() function
plt.show()
                      
                       

Output:

The above plot shows the distribution of pulse rate of the peoples with respect to the kind i.e, rest, walking, running.

Method 2: Using displot() method

In this method, we are using ‘diamonds’ data provided by seaborn.

Python

# importing library
import seaborn as sns
 
# loading diamonds dataset provided by seaborn
diam = sns.load_dataset('diamonds')
 
# printing the dataset
print(diam)
                      
                       

Output:

Example 1: Plotting ECDF plot using displot() on penguins dataset provided by seaborn.

Python

# importing libraries
import seaborn as sns
import matplotlib.pyplot as plt
 
# loading diamonds dataset provided by seaborn
diam = sns.load_dataset('diamonds')
 
# making ECDF plot using displot() on depth
# of the diamonds
sns.displot(data=diam,x='depth',kind='ecdf')
 
# visualizing the plot using matplotlib.pyplot
# show() function
plt.show()
                      
                       

Output:

Example 2: Plotting ECDF plot using displot() when we have multiple distributions with default setting.

Python

# importing libraries
import seaborn as sns
import matplotlib.pyplot as plt
 
# loading diamonds dataset provided by seaborn
diam = sns.load_dataset('diamonds')
 
# making ECDF plot using displot() on depth
# of the diamond on the basis of cut
sns.displot(data=diam,x='depth',kind='ecdf',hue='cut')
 
# visualizing the plot using matplotlib.pyplot
# show() function
plt.show()
                      
                       

Output:

The above plot shows the depth of the diamonds on the basis of their cut.

Example 3: Making ECDF plot using displot() by setting up the color.

Python

# importing libraries
import seaborn as sns
import matplotlib.pyplot as plt
 
# loading diamonds dataset provided by seaborn
diam = sns.load_dataset('diamonds')
 
# making ECDF plot using displot() on table
# column on the basis of cut of diamond
# setting up the color of plot by setting
# up the palette to icefire_r
sns.displot(data=diam,x='table',kind='ecdf',hue='cut',palette='icefire_r')
 
# visualizing the plot using matplotlib.pyplot
# show() function
plt.show()
                      
                       

Output:

We can set the palette to Accent_r, magma_r, plasma, plasma_r, etc, according to our choice, it has many other options available.



Next Article
How To Make Simple Facet Plots with Seaborn Catplot in Python?
author
srishivansh5404
Improve
Article Tags :
  • Python
  • Technical Scripter
  • Python-Seaborn
  • Technical Scripter 2020
Practice Tags :
  • python

Similar Reads

  • How To Make Ridgeline plot in Python with Seaborn?
    Prerequisite: Seaborn Ridgeline plot is a set of overlapped density plots that help in comparing multiple distributions among datasets. The Ridgeline plots look like a mountain range, they can be quite useful for visualizing changes in distributions over time or space. Sometimes it is also known as
    2 min read
  • How To Make Simple Facet Plots with Seaborn Catplot in Python?
    Seaborn is an amazing visualization library for statistical graphics plotting in Python. It provides beautiful default styles and color palettes to make statistical plots more attractive. It is built on the top of matplotlib library and also closely integrated into the data structures from pandas.Se
    2 min read
  • How to Make Horizontal Violin Plot with Seaborn in Python?
    In this article, we are going to plot a horizontal Violin plot with seaborn. We can use two methods for the Drawing horizontal Violin plot, Violinplot() and catplot(). Method 1: Using violinplot() A violin plot plays a similar activity that is pursued through whisker or box plot do. As it shows seve
    3 min read
  • How to Make Grouped Violinplot with Seaborn in Python?
    This article depicts how to make a grouped violinplot with Seaborn in python. Violinplot is a great way of visualizing the data as a combination of the box plot with the kernel density plots to produce a new type of plot. For this article, we will be using the iris dataset to plot data. This comes i
    3 min read
  • How to Save Seaborn Plot to a File in Python?
    Seaborn provides a way to store the final output in different desired file formats like .png, .pdf, .tiff, .eps, etc. Let us see how to save the output graph to a specific file format. Saving a Seaborn Plot to a File in Python Import the inbuilt penguins dataset from seaborn package using the inbuil
    2 min read
  • How to Make ECDF Plot with ggplot2 in R?
    Empirical Cumulative Distribution Function Plot (ECDF) helps us to visualize one or more distributions. ECDF plot is a great alternative for histograms and it has the ability to show the full range of data without the need for various parameters. In this article, we will discuss how to draw an ECDF
    3 min read
  • How To Align Kde Plot With Strip Plot In Seaborn?
    A high-level interface for creating attractive and informative statistical graphics is offered by a powerful python library Seaborn. One of the most common tasks in data visualization is aligning different types of plots in one graph to gain insights into the data. In this article, we will understan
    4 min read
  • How To Make Density Plot in Python with Altair?
    Density plots are a variation of Histograms that are used to observe the distribution of a variable in data set over a continuous interval or a time period. The peaks of a Density Plot indicate where values are concentrated over an interval. Compared to Histograms, Density Plots are better at determ
    2 min read
  • How To Place Legend Outside the Plot with Seaborn in Python?
    Seaborn is a Python data visualization library based on matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. Basically, it helps us stylize our basic plot made using matplotlib. Moreover, it also provides us different plotting techniques to ease
    2 min read
  • How To Make Violinpot with data points in Seaborn?
    A violin plot plays a similar activity that is pursued through whisker or box plot do. As it shows several quantitative data across one or more categorical variables. It can be an effective and attractive way to show multiple data at several units. A “wide-form” Data Frame helps to maintain each num
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences