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
  • Data Science
  • Data Science Projects
  • Data Analysis
  • Data Visualization
  • Machine Learning
  • ML Projects
  • Deep Learning
  • NLP
  • Computer Vision
  • Artificial Intelligence
Open In App
Next Article:
R - Charts and Graphs
Next article icon

Basic Python Charts

Last Updated : 03 Jan, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Python Chart is part of data visualization to present data in a graphical format. It helps people understand the significance of data by summarizing and presenting huge amounts of data in a simple and easy-to-understand format and helps communicate information clearly and effectively.

In this article, we will be discussing various Python Charts that help to visualize data in various dimensions such as Histograms, Column charts, Box plot charts, Line charts, and so on.

Table of Content

  • Python Charts for Data Visualization
  • Histogram
  • Column Chart
  • Box plot chart
  • Pie Chart
  • Scatter Chart
  • Line Chart
  • Area Chart
  • Heatmap
  • Bubble Chart
  • Radar Chart
  • Conclusion

Python Charts for Data Visualization

In Python there are number of various charts charts that are used to visualize data on the basis of different factors. For exploratory data analysis, reporting, or storytelling we can use these charts as a fundamental tool. Consider this different given Datasets for which we will be plotting different charts:

Histogram

The histogram represents the frequency of occurrence of specific phenomena which lie within a specific range of values and are arranged in consecutive and fixed intervals. In the below code histogram is plotted for Age, Income, Sales, So these plots in the output show frequency of each unique value for each attribute.

Python
# import pandas and matplotlib import pandas as pd import matplotlib.pyplot as plt  # create 2D array of table given above data = [['E001', 'M', 34, 123, 'Normal', 350],         ['E002', 'F', 40, 114, 'Overweight', 450],         ['E003', 'F', 37, 135, 'Obesity', 169],         ['E004', 'M', 30, 139, 'Underweight', 189],         ['E005', 'F', 44, 117, 'Underweight', 183],         ['E006', 'M', 36, 121, 'Normal', 80],         ['E007', 'M', 32, 133, 'Obesity', 166],         ['E008', 'F', 26, 140, 'Normal', 120],         ['E009', 'M', 32, 133, 'Normal', 75],         ['E010', 'M', 36, 133, 'Underweight', 40] ]  # dataframe created with # the above data array df = pd.DataFrame(data, columns = ['EMPID', 'Gender',                                      'Age', 'Sales',                                     'BMI', 'Income'] )  # create histogram for numeric data df.hist()  # show plot plt.show() 

Output:

HIstogram-Chart

Histogram Chart


Column Chart

A column chart is used to show a comparison among different attributes, or it can show a comparison of items over time.

Python
# Dataframe of previous code is used here  # Plot the bar chart for numeric values # a comparison will be shown between # all 3 age, income, sales df.plot.bar()  # plot between 2 attributes plt.bar(df['Age'], df['Sales']) plt.xlabel("Age") plt.ylabel("Sales") plt.show() 

Output:

Box plot chart

A box plot is a graphical representation of statistical data based on the minimum, first quartile, median, third quartile, and maximum. The term “box plot” comes from the fact that the graph looks like a rectangle with lines extending from the top and bottom. Because of the extending lines, this type of graph is sometimes called a box-and-whisker plot.

Python
# For each numeric attribute of dataframe df.plot.box()  # individual attribute box plot plt.boxplot(df['Income']) plt.show() 

Output:

Pie Chart

A pie chart shows a static number and how categories represent part of a whole the composition of something. A pie chart represents numbers in percentages, and the total sum of all segments needs to equal 100%.

Python
plt.pie(df['Age'], labels = {"A", "B", "C",                              "D", "E", "F",                              "G", "H", "I", "J"},                               autopct ='% 1.1f %%', shadow = True)  plt.show()   plt.pie(df['Income'], labels = {"A", "B", "C",                                  "D", "E", "F",                                  "G", "H", "I", "J"},                                   autopct ='% 1.1f %%', shadow = True)  plt.show()   plt.pie(df['Sales'], labels = {"A", "B", "C",                              "D", "E", "F",                              "G", "H", "I", "J"},  autopct ='% 1.1f %%', shadow = True)  plt.show()  

Output:

Scatter Chart

A scatter chart shows the relationship between two different variables and it can reveal the distribution trends. It should be used when there are many different data points, and you want to highlight similarities in the data set. This is useful when looking for outliers and for understanding the distribution of your data.

Python
# scatter plot between income and age plt.scatter(df['income'], df['age']) plt.show() 

Output:

Line Chart

A Line Charts are effective in showing trends over time. By using line plots you can connect data points with straight lines that make it easy to visualize the overall dataset.

Python
import matplotlib.pyplot as plt  # Example: Line Chart x = [1, 2, 3, 4, 5] y = [2, 4, 6, 8, 10]  plt.plot(x, y) plt.xlabel('X-axis Label') plt.ylabel('Y-axis Label') plt.title('Line Chart Example') plt.show() 

Output:


Line-Chart

LIne Chart


Area Chart

Area Chart are similar to line charts but there is area difference between the line and the x-axis is generally filled. They are helpful generally in showing magnitude over time.

Python
import matplotlib.pyplot as plt # Example: Area Chart x = [1, 2, 3, 4, 5] y = [2, 4, 6, 8, 10] plt.fill_between(x, y, color='skyblue', alpha=0.4) plt.xlabel('X-axis Label') plt.ylabel('Y-axis Label') plt.title('Area Chart Example') plt.show() 

Output:


Area-Chart

Area Chart


Heatmap

Heatmap use coding of color to represent the values of Matrix. Heatmap helps in finding correlations and patterns in large dataset.

Python
import seaborn as sns import numpy as np # Example: Heatmap data = np.random.rand(10, 12) sns.heatmap(data, cmap='viridis') plt.title('Heatmap Example') plt.show() 

Output:


HeatMap

HeatMap


Bubble Chart

By using Bubble Chart , you can add third dimension in scatter plot. The bubble chart represents the third variable with the size of the Bubble.

Python
import matplotlib.pyplot as plt import numpy as np # Example: Bubble Chart x = np.random.rand(50) y = np.random.rand(50) sizes = np.random.rand(50) * 100 plt.scatter(x, y, s=sizes, alpha=0.5) plt.title('Bubble Chart Example') plt.show() 

Output:

Bubble-Chart

Bubble Chart


Radar Chart

Radar Chart is ideal chart that displays multivariate data in form of two- dimensional chart. Each variable is present on an axis that radiates on an axis radiating from the center.

Python
import matplotlib.pyplot as plt import numpy as np # Example: Radar Chart categories = ['A', 'B', 'C', 'D', 'E'] values = [4, 2, 5, 3, 1] angles = np.linspace(0, 2 * np.pi, len(categories), endpoint=False) values += values[:1] # Ensure that angles array has the same length as values angles = np.concatenate((angles, [angles[0]])) plt.polar(angles, values, marker='o') plt.title('Radar Chart Example') plt.show() 

Output:

Radar-Chart

Radar Chart


Conclusion

In conclusion you will delve into the basic realm of Python Charts offers a foundational understanding of visualizing data, these examples provide various Python Charts including histograms, column charts, box plots, pie charts and scatter plots.



Next Article
R - Charts and Graphs

M

Mohityadav
Improve
Article Tags :
  • Data Science
  • python
  • Python-Miscellaneous
Practice Tags :
  • python

Similar Reads

  • R - Bar Charts
    Bar charts provide an easy method of representing categorical data in the form of bars. The length or height of each bar represents the value of the category it represents. In R, bar charts are created using the function barplot(), and it can be applied both for vertical and horizontal charts. Synta
    4 min read
  • R - Charts and Graphs
    R language is mostly used for statistics and data analytics purposes to represent the data graphically in the software. To represent those data graphically, charts and graphs are used in R.  R - graphs There are hundreds of charts and graphs present in R. For example, bar plot, box plot, mosaic plot
    6 min read
  • Plot a Pie Chart in Python using Matplotlib
    A Pie Chart is a circular statistical plot that can display only one series of data. The area of the chart is the total percentage of the given data. Pie charts in Python are widely used in business presentations, reports, and dashboards due to their simplicity and effectiveness in displaying data d
    8 min read
  • Creating Charts using openpyxl
    Charts are a powerful way to visualize data, making it easier to analyze and present information. While working with Excel files in Python, the library openpyxl comes into the picture and can be used as a tool for automating tasks like reading data, writing data, formatting cells, and of course crea
    7 min read
  • Visualizing Data with Python's Leather Library
    Data visualization is a crucial aspect of data analysis, enabling data scientists and analysts to interpret complex data sets and derive meaningful insights. Among the myriad of Python libraries available for data visualization, Leather stands out for its simplicity and efficiency. This article delv
    8 min read
  • Interactive Charts using Pywedge package
    In Machine Learning and Data Science, one of the toughest jobs is to understand the raw data and make it fit for applying different models over it to make predictions. For understanding purpose, we make use of different processes like checking statistical figures such as mean, median, mode, finding
    4 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 ins
    8 min read
  • Matplotlib Cheatsheet [2025 Updated]- Download pdf
    Mastering data visualization is essential for understanding and presenting data in the best way possible and among the most commonly accessed libraries in Python are the data visualizations that are provided. This "Matplotlib Cheat Sheet" is structured in order to present a quick reference to some o
    8 min read
  • Waterfall Charts in Python
    Waterfall charts are a powerful visualization tool used to understand the cumulative effect of sequentially introduced positive or negative values. They are particularly useful in financial analysis, where they help illustrate how an initial value is affected by a series of intermediate positive or
    9 min read
  • Violin Plot for Data Analysis
    Data visualization is instrumental in understanding and interpreting data trends. Various visualization charts aid in comprehending data, with the violin plot standing out as a powerful tool for visualizing data distribution. This article aims to explore the fundamentals, implementation, and interpr
    8 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