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 a Time Series Plot with Rolling Average in Python?
Next article icon

How To Make Ridgeline plot in Python with Seaborn?

Last Updated : 23 May, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

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 “joyplot”, in reference to the iconic cover art for Joy Division’s album Unknown Pleasures. In this article, We will see how to generate Ridgeline plots for the dataset. 

Installation

Like any another python library, seaborn can be easily installed using pip:

pip install seaborn  

This library is a part of Anaconda distribution and usually works just by import if your IDE is supported by Anaconda, but it can be installed too by the following command:

conda install seaborn  

Procedure

  • Load the packages required to generate the Ridgeline plot with Python.
  • Read the Dataset. In this example, we use the read_csv() method to load the dataset. In the given example we will only display the top 5 entries using the head() method.
  • Generate RidgePlot. The Ridgeline Plot uses faceting meaning it creates small multiples, in a single column. To generate Ridgeline Plot Seaborn uses FacetGrid() method and all required information should be passed to it

Syntax: seaborn.FacetGrid(data, row, col, hue, palette, aspect, height)

Parameters:

  1. data: Tidy (“long-form”) dataframe where each column is a variable and each row is an observation.
  2. row, col, hue: Variables that define subsets of the data, which will be drawn on separate facets in the grid.
  3. height: Height (in inches) of each facet.
  4. aspect: Aspect ratio of each facet, so that aspect * height gives the width of each facet in inches.
  5. palette: Colors to use for the different levels of the hue variable.
  • Use the map() method to creates a density plot in each element of the grid. In this example, we need a density plot so use kdeplot() method which available in Seaborn.
     

Sample Database: Dataset used in the following example is downloaded from kaggle.com. The following link can be used for the same.

 Example:

Python3

import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
from sklearn import preprocessing
  
df = pd.read_csv("titanic_train.csv")
df.dropna()
  
le = preprocessing.LabelEncoder()
df["Sex"] = le.fit_transform(df["Sex"])
  
  
rp = sns.FacetGrid(df, row="Sex", hue="Sex", aspect=5, height=1.25)
  
rp.map(sns.kdeplot, 'Survived', clip_on=False,
       shade=True, alpha=0.7, lw=4, bw=.2)
  
rp.map(plt.axhline, y=0, lw=4, clip_on=False)
                      
                       

Output :



Next Article
How to Make a Time Series Plot with Rolling Average in Python?
author
abhijitmahajan772
Improve
Article Tags :
  • Python
  • Python-Seaborn
Practice Tags :
  • python

Similar Reads

  • How to Make ECDF Plot with Seaborn in Python?
    Prerequisites:  Seaborn In this article, we are going to make the ECDF plot with Seaborn Library. ECDF PlotECDF 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
    5 min read
  • How To Make Scatter Plot with Regression Line using Seaborn in Python?
    In this article, we will learn how to male scatter plots with regression lines using Seaborn in Python. Let's discuss some concepts : Seaborn : Seaborn is a tremendous visualization library for statistical graphics plotting in Python. It provides beautiful default styles and color palettes to make s
    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 a Time Series Plot with Rolling Average in Python?
    Time Series Plot is used to observe various trends in the dataset over a period of time. In such problems, the data is ordered by time and can fluctuate by the unit of time considered in the dataset (day, month, seconds, hours, etc.). When plotting the time series data, these fluctuations may preven
    4 min read
  • How To Add Regression Line Per Group with Seaborn in Python?
    In this article, we will learn how to add a regression line per group with Seaborn in Python. Seaborn has multiple functions to form scatter plots between two quantitative variables. For example, we can use lmplot() function to make the required plot. What is Regression Line? A regression line is ju
    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 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 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 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
  • Scatter Plot with Marginal Histograms in Python with Seaborn
    Prerequisites: Seaborn  Scatter Plot with Marginal Histograms is basically a joint distribution plot with the marginal distributions of the two variables. In data visualization, we often plot the joint behavior of two random variables (bi-variate distribution) or any number of random variables. But
    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