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 ECDF Plot with Seaborn in Python?
Next article icon

How to Save Seaborn Plot to a File in Python?

Last Updated : 08 Sep, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

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 inbuilt function load_dataset.

Python3
# Import the seaborn package import seaborn as sns  # load the inbuilt "penguins" dataset using # seaborn inbuilt function load_dataset data = sns.load_dataset("penguins")  # print the first 6 data data.head() 
Save Seaborn Plot to a File
Save Seaborn Plot to a File

Saving the plot as .png:

Finally, use savefig function and give the desired name and file type to store the plot. The below example stores the plot as a .png file in the current working directory. 

Python3
scatter_plot = sns.scatterplot(     x=data['bill_length_mm'], y=data['bill_depth_mm'], hue=data['sex'])  # use get_figure function and store the plot i # n a variable (scatter_fig) scatter_fig = scatter_plot.get_figure()  # use savefig function to save the plot and give # a desired name to the plot. scatter_fig.savefig('scatterplot.png')  # this will store the plot in current working directory 

Output:

Save Seaborn Plot to a File in Python

Saving the Seaborn graph as .jpg

Here we want to save the seaborn graph as a Joint Photographic Experts Group file so we are giving it's extension as .jpg.

Python3
scatter_fig.savefig('scatterplot.jpg')  # this will store the plot in current working directory 

Output:

Save Seaborn Plot to a File in Python

Saving the Seaborn graph as .tiff

Here we want to save the seaborn graph as Tag Image file format file so we are giving it's extension as .tiff.

Python3
scatter_fig.savefig('scatterplot.tiff')  # this will store the plot in current working directory 

Output:

Save Seaborn Plot to a File in Python

To save the seaborn plot to a specific folder,

Here we want to save the seaborn graph in a particular folder so we are giving the specified path for saving it.

Python3
scatter_fig.savefig(r'C:\Users\Documents\test\Plots\scatterplot.png')  # this will store the plot in specified directory 

Output:

Save Seaborn Plot to a File in Python

Next Article
How to Make ECDF Plot with Seaborn in Python?

J

jssuriyakumar
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 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 Set Title On Seaborn Jointplot? - Python
    Seaborn Jointplot is a powerful tool for visualizing the relationship between two variables along with their marginal distributions. To set a title on a Seaborn jointplot in Python, you can use the fig.suptitle() method. This method is used to add a title to the figure-level object created by the sn
    3 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
  • Python - seaborn.pointplot() method
    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 to the data structures from pandas. sea
    3 min read
  • How to Plot a Dashed Line on Seaborn Lineplot?
    Seaborn is a popular data visualization library in Python that is built on top of Matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. One common requirement in data visualization is to differentiate between various lines on a plot. This can be
    2 min read
  • How to change figure size in Plotly in Python
    In this article, we will discuss how we can change the figure size in Plotly in Python. Let's firstly take about Plotly in Python. Plotly   Python library provides us with an interactive open-source Plotly library that can support over 40 unique chart types that cover a wide list of statistical, fin
    4 min read
  • How to Add a Title to Seaborn Plots?
    In this article, we will discuss how to add a title to Seaborn Plots in Python. Method 1: Adding title using set methodset method takes 1 argument "title" as a parameter which stores Title of a plot. Syntax set(title="Title of a plot") Example: Here, we are going to create a dataframe with months an
    2 min read
  • How to Save a Plot to a File Using Matplotlib?
    Matplotlib is a popular Python library to create plots, charts, and graphs of different types. show() is used to plot a plot, but it doesn't save the plot to a file. In this article, we will see various methods through which a Matplotlib plot can be saved as an image file. Methods to Save a Plot in
    3 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