Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • 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
  • Pandas
  • Numpy
  • Seaborn
  • Ploty
  • Data visualization
  • Data Analysis
  • Power BI
  • Tableau
  • Machine Learning
  • Deep Learning
  • NLP
  • Computer Vision
  • Data Science for Beginners
  • Data Science interview questions
  • Data analysis interview questions
  • NLP Interview questions
Open In App
Next Article:
How to set border for wedges in Matplotlib pie chart?
Next article icon

Plot a Pie Chart in Python using Matplotlib

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

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 distributions. In this article, we will explore how to create a pie chart in Python using the Matplotlib library, one of the most widely used libraries for data visualization in Python.

Table of Content

  • Why Use Pie Charts?
  • Basic Structure of a Pie Chart
  • Plotting a Pie Chart in Matplotlib
  • Customizing Pie Charts
  • Creating a Nested Pie Chart in Python
  • Creating 3D Pie Charts

Why Use Pie Charts?

Pie charts provide a visual representation of data that makes it easy to compare parts of a whole. They are particularly useful when:

  • Displaying relative proportions or percentages.
  • Summarizing categorical data.
  • Highlighting significant differences between categories.

However, while pie charts are useful, they also have limitations. They can become cluttered with too many categories or lead to misinterpretation if not designed thoughtfully. Despite this, a well-crafted pie chart using Matplotlib can significantly enhance the presentation of your data.

Basic Structure of a Pie Chart

A pie chart consists of slices that represent different categories. The size of each slice is proportional to the quantity it represents. The following components are essential when creating a pie chart in Matplotlib:

  • Data: The values or counts for each category.
  • Labels: The names of each category, which will be displayed alongside the slices.
  • Colors: Optional, but colors can be used to differentiate between slices effectively.

Matplotlib API has pie() function in its pyplot module which create a pie chart representing the data in an array.  let's create pie chart in python.

Syntax: matplotlib.pyplot.pie(data, explode=None, labels=None, colors=None, autopct=None, shadow=False)

Parameters:

  • data represents the array of data values to be plotted, the fractional area of each slice is represented by data/sum(data)
  • labels is a list of sequence of strings which sets the label of each wedge.
  • color attribute is used to provide color to the wedges.
  • autopct is a string used to label the wedge with their numerical value.
  • shadow is used to create shadow of wedge.

Plotting a Pie Chart in Matplotlib

Let's create a simple pie chart using the pie() function in Matplotlib. This function is a powerful and easy way to visualize the distribution of categorical data.

Python
# Import libraries from matplotlib import pyplot as plt import numpy as np   # Creating dataset cars = ['AUDI', 'BMW', 'FORD',         'TESLA', 'JAGUAR', 'MERCEDES']  data = [23, 17, 35, 29, 12, 41]  # Creating plot fig = plt.figure(figsize=(10, 7)) plt.pie(data, labels=cars)  # show plot plt.show() 

Output:

pie-chart-python

Customizing Pie Charts

Once you are familiar with the basics of pie charts in Matplotlib, you can start customizing them to fit your needs. A pie chart can be customized on the basis several aspects:

  • startangle: This attribute allows you to rotate the pie chart in Python counterclockwise around the x-axis by the specified degrees.. By adjusting this angle, you can change the starting position of the first wedge, which can improve the overall presentation of the chart.
  • shadow: This boolean attribute adds a shadow effect below the rim of the pie. Setting this to True can make your chart stand out and give it a more three-dimensional appearance, enhancing the overall look of your pie chart in Matplotlib.
  • wedgeprops: This parameter accepts a Python dictionary to customize the properties of each wedge in the pie chart. You can specify various attributes such as linewidth, edgecolor, and facecolor. This level of customization allows you to enhance the visual distinction between wedges, making your matplotlib pie chart more informative.
  • frame: When set to True, this attribute draws a frame around the pie chart. This can help emphasize the chart's boundaries and improve its visibility, making it clearer when presenting data.
  • autopct: This attribute controls how the percentages are displayed on the wedges. You can customize the format string to define the appearance of the percentage labels on each slice.

The explode parameter separates a portion of the chart, and colors define each wedge's color. The autopct function customizes text display, and legend and title functions enhance chart readability and aesthetics.

Python
# Import libraries import numpy as np import matplotlib.pyplot as plt   # Creating dataset cars = ['AUDI', 'BMW', 'FORD',         'TESLA', 'JAGUAR', 'MERCEDES']  data = [23, 17, 35, 29, 12, 41]   # Creating explode data explode = (0.1, 0.0, 0.2, 0.3, 0.0, 0.0)  # Creating color parameters colors = ("orange", "cyan", "brown",           "grey", "indigo", "beige")  # Wedge properties wp = {'linewidth': 1, 'edgecolor': "green"}  # Creating autocpt arguments   def func(pct, allvalues):     absolute = int(pct / 100.*np.sum(allvalues))     return "{:.1f}%\n({:d} g)".format(pct, absolute)   # Creating plot fig, ax = plt.subplots(figsize=(10, 7)) wedges, texts, autotexts = ax.pie(data,                                   autopct=lambda pct: func(pct, data),                                   explode=explode,                                   labels=cars,                                   shadow=True,                                   colors=colors,                                   startangle=90,                                   wedgeprops=wp,                                   textprops=dict(color="magenta"))  # Adding legend ax.legend(wedges, cars,           title="Cars",           loc="center left",           bbox_to_anchor=(1, 0, 0.5, 1))  plt.setp(autotexts, size=8, weight="bold") ax.set_title("Customizing pie chart")  # show plot plt.show() 

Output:

pie-chart-python

By leveraging the capabilities of the plt.pie() function in Matplotlib, we can create informative and visually appealing pie charts that help to communicate with data effectively. Whether you are presenting data to stakeholders or creating visual aids for your reports, mastering the art of plotting pie charts in Python is a valuable skill.

Creating a Nested Pie Chart in Python

A nested pie chart is an effective way to represent hierarchical data, allowing you to visualize multiple categories and subcategories in a single view. In Matplotlib, you can create a nested pie chart by overlaying multiple pie charts with different radii. Below, we’ll explore how to create this type of chart in Python.

Here’s a simple example of how to create a nested pie chart using Matplotlib:

Python
# Import libraries from matplotlib import pyplot as plt import numpy as np   # Creating dataset size = 6 cars = ['AUDI', 'BMW', 'FORD',         'TESLA', 'JAGUAR', 'MERCEDES']  data = np.array([[23, 16], [17, 23],                  [35, 11], [29, 33],                  [12, 27], [41, 42]])  # normalizing data to 2 pi norm = data / np.sum(data)*2 * np.pi  # obtaining ordinates of bar edges left = np.cumsum(np.append(0,                            norm.flatten()[:-1])).reshape(data.shape)  # Creating color scale cmap = plt.get_cmap("tab20c") outer_colors = cmap(np.arange(6)*4) inner_colors = cmap(np.array([1, 2, 5, 6, 9,                               10, 12, 13, 15,                               17, 18, 20]))  # Creating plot fig, ax = plt.subplots(figsize=(10, 7),                        subplot_kw=dict(polar=True))  ax.bar(x=left[:, 0],        width=norm.sum(axis=1),        bottom=1-size,        height=size,        color=outer_colors,        edgecolor='w',        linewidth=1,        align="edge")  ax.bar(x=left.flatten(),        width=norm.flatten(),        bottom=1-2 * size,        height=size,        color=inner_colors,        edgecolor='w',        linewidth=1,        align="edge")  ax.set(title="Nested pie chart") ax.set_axis_off()  # show plot plt.show() 

Output:

pie-chart-python
  • The outer pie chart represents the main categories, while the inner pie chart represents subcategories related to one of those main categories. This structure is particularly useful for showing proportions within proportions, helping viewers quickly grasp the relationships within the data.
  • Center Circle: The centre_circle is added to create the donut effect, providing a clean visual separation between the outer and inner pie charts.

As with a regular pie chart in Python, you can customize various attributes, such as startangle, shadow, autopct, and wedgeprops, to enhance the overall aesthetics of your nested pie chart.

Creating 3D Pie Charts

To create a proper 3D pie chart in Matplotlib, you can use the following code snippet. Note that Matplotlib does not have a direct function for 3D pie charts, but we can simulate it with a 3D surface plot or use a workaround with 2D pie charts:


Conclusion

In this article, we explored the fundamentals of creating and customizing pie charts in Python using the Matplotlib library. From constructing a simple pie chart in Matplotlib to visualizing more complex datasets with 2D and 3D pie charts in Python, we have covered various aspects that can enhance the effectiveness of our visualizations.

By utilizing plt.pie in Python, we learned how to present categorical data clearly, making it easier to convey insights to stakeholders.


Next Article
How to set border for wedges in Matplotlib pie chart?

J

jeeteshgavande30
Improve
Article Tags :
  • Data Science
  • Python-matplotlib
  • python
Practice Tags :
  • python

Similar Reads

    Introduction

    Matplotlib Tutorial
    Matplotlib is an open-source visualization library for the Python programming language, widely used for creating static, animated and interactive plots. It provides an object-oriented API for embedding plots into applications using general-purpose GUI toolkits like Tkinter, Qt, GTK and wxPython. It
    5 min read
    Environment Setup for Matplotlib
    Matplotlib is an overall package for creating static, animated, and interactive visualizations in Python. It literally opens up a whole new world of possibilities for you! Especially when it is used with Numpy or Pandas library, one can do unimaginable things. The plots give may give a new insight a
    1 min read
    Using Matplotlib with Jupyter Notebook
    Jupyter Notebook is a free, open-source web app that lets you create and share documents with live code and visualizations. It is commonly used for tasks like cleaning and transforming data, doing statistical analysis, creating visualizations and machine learning.Matplotlib is a popular Python libra
    2 min read
    Introduction to Matplotlib
    Matplotlib is a powerful and versatile open-source plotting library for Python, designed to help users visualize data in a variety of formats. Developed by John D. Hunter in 2003, it enables users to graphically represent data, facilitating easier analysis and understanding. If you want to convert y
    4 min read
    Matplotlib Pyplot
    Pyplot is a submodule of the Matplotlib library in python and beginner-friendly tool for creating visualizations providing a MATLAB-like interface, to generate plots with minimal code. How to Use Pyplot for Plotting?To use Pyplot we must first download the Matplotlib module. For this write the follo
    2 min read
    Matplotlib - Axes Class
    Matplotlib is one of the Python packages which is used for data visualization. You can use the NumPy library to convert data into an array and numerical mathematics extension of Python. Matplotlib library is used for making 2D plots from data in arrays. Axes class Axes is the most basic and flexible
    4 min read

    Multiple Plots

    How to Create Multiple Subplots in Matplotlib in Python?
    To create multiple plots use matplotlib.pyplot.subplots method which returns the figure along with the objects Axes object or array of Axes object. nrows, ncols attributes of subplots() method determine the number of rows and columns of the subplot grid. By default, it returns a figure with a single
    3 min read
    How to Add Title to Subplots in Matplotlib?
    In this article, we will see how to add a title to subplots in Matplotlib? Let's discuss some concepts : Matplotlib : Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work
    3 min read
    How to Set a Single Main Title for All the Subplots in Matplotlib?
    A title in Matplotlib library describes the main subject of plotting the graphs. Setting a title for just one plot is easy using the title() method. By using this function only the individual title plots can be set but not a single title for all subplots. Hence, to set a single main title for all su
    2 min read
    How to Turn Off the Axes for Subplots in Matplotlib?
    In this article, we are going to discuss how to turn off the axes of subplots using matplotlib module. We can turn off the axes for subplots and plots using the below methods: Method 1: Using matplotlib.axes.Axes.axis() To turn off the axes for subplots, we will matplotlib.axes.Axes.axis() method he
    2 min read
    How to Create Different Subplot Sizes in Matplotlib?
    In this article, we will learn different ways to create subplots of different sizes using Matplotlib. It provides 3 different methods using which we can create different subplots of different sizes. Methods available to create subplot:  Gridspecgridspec_kwsubplot2gridCreate Different Subplot Sizes i
    4 min read
    How to set the spacing between subplots in Matplotlib in Python?
    Let's learn how to set the spacing between the subplots in Matplotlib to ensure clarity and prevent the overlapping of plot elements, such as axes labels and titles.Let's create a simple plot with the default spacing to see how subplots can sometimes become congested.Pythonimport numpy as np import
    3 min read

    Working with Legends

    Matplotlib.pyplot.legend() in Python
    A legend is an area describing the elements of the graph. In the Matplotlib library, there’s a function called legend() which is used to place a legend on the axes. In this article, we will learn about the Matplotlib Legends.Python Matplotlib.pyplot.legend() SyntaxSyntax: matplotlib.pyplot.legend(["
    6 min read
    Matplotlib.axes.Axes.legend() in Python
    Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
    2 min read
    Change the legend position in Matplotlib
    In this article, we will learn how to Change the legend position in Matplotlib. Let's discuss some concepts :Matplotlib is a tremendous visualization library in Python for 2D plots of arrays. Matplotlib may be a multi-platform data visualization library built on NumPy arrays and designed to figure w
    2 min read
    How to Change Legend Font Size in Matplotlib?
    Matplotlib is a library for creating interactive Data visualizations in Python. The functions in Matplotlib make it work like MATLAB software. The legend method in Matplotlib describes the elements in the plot. In this article, we are going to Change Legend Font Size in Matplotlib. Using pyplot.lege
    3 min read
    How Change the vertical spacing between legend entries in Matplotlib?
    Prerequisites: Matplotlib In this article, we will see how can we can change vertical space between labels of a legend in our graph using matplotlib, Here we will take two different examples to showcase our graph. Approach: Import required module.Create data.Change the vertical spacing between label
    2 min read
    Use Multiple Columns in a Matplotlib Legend
    Legends helps to understand what each element in the plot represents. They help to understand the meaning behind different elements like colors, markers or line styles. If a plot contains many labels a single-column legend may:Take up too much vertical spaceOverlap with the plot andLook messy or clu
    3 min read
    How to Create a Single Legend for All Subplots in Matplotlib?
    The subplot() function in matplotlib helps to create a grid of subplots within a single figure. In a figure, subplots are created and ordered row-wise from the top left. A legend in the Matplotlib library basically describes the graph elements. The legend() can be customized and adjusted anywhere in
    3 min read
    How to manually add a legend with a color box on a Matplotlib figure ?
    A legend is basically an area in the plot which describes the elements present in the graph. Matplotlib provides an inbuilt method named legend() for this purpose. The syntax of the method is below : Example: Adding Simple legend Python3 # Import libraries import matplotlib.pyplot as plt # Creating
    2 min read
    How to Place Legend Outside of the Plot in Matplotlib?
    Placing the legend outside of the plot in Matplotlib helps make the chart cleaner and easier to read, especially when dealing with multiple lines or subplots. Instead of cluttering the plot area, the legend can be positioned beside or above the plot, giving more space to the data. Let’s explore diff
    3 min read
    How to Remove the Legend in Matplotlib?
    Matplotlib is one of the most popular data visualization libraries present in Python. Using this matplotlib library, if we want to visualize more than a single variable, we might want to explain what each variable represents. For this purpose, there is a function called legend() present in matplotli
    5 min read
    Remove the legend border in Matplotlib
    A legend helps explain the elements in a plot, and for adding a legend to a plot in Matplotlib, we use the legend() function. A border is added by default to the legend, but there may be some cases when you will prefer not having a border for a cleaner appearance. We will demonstrate how to do it qu
    2 min read

    Line Chart

    Line chart in Matplotlib - Python
    Matplotlib is a data visualization library in Python. The pyplot, a sublibrary of Matplotlib, is a collection of functions that helps in creating a variety of charts. Line charts are used to represent the relation between two data X and Y on a different axis. In this article, we will learn about lin
    6 min read
    Line plot styles in Matplotlib
    Line plots are important data visualization elements that can be used to identify relationships within the data. Using matplotlib.pyplot.plot() function we can plot line plots. Styling tools in this helps us customize line plots according to our requirements which helps in better representations. Li
    3 min read
    Plot Multiple lines in Matplotlib
    In this article, we will learn how to plot multiple lines using matplotlib in Python. Let's discuss some concepts:Matplotlib: Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed
    6 min read
    Change the line opacity in Matplotlib
    Changing Line Opacity in Matplotlib means adjusting the transparency level of a line in a plot. Opacity controls how much the background or overlapping elements are visible through the line. A fully opaque line is solid, while a more transparent line allows other elements behind it to be seen. Let's
    3 min read
    Increase the thickness of a line with Matplotlib
    Prerequisites: Matplotlib Matplotlib is the most widely used library for plotting graphs with the available dataset. Matplotlib supports line chart which are used to represent data over a continuous time span. In line chart, the data value is plotted as points and later connected by a line to show t
    3 min read
    How to Fill Between Multiple Lines in Matplotlib?
    With the use of the fill_between()  function in the Matplotlib library in Python, we can easily fill the color between any multiple lines or any two horizontal curves on a 2D plane. Syntax: matplotlib.pyplot.fill_between(x, y1, y2=0, where=None, step=None, interpolate=False, *, data=None, **kwargs)
    2 min read

    Bar Plot

    Bar Plot in Matplotlib
    A bar plot uses rectangular bars to represent data categories, with bar length or height proportional to their values. It compares discrete categories, with one axis for categories and the other for values.Consider a simple example where we visualize the sales of different fruits:Pythonimport matplo
    5 min read
    Draw a horizontal bar chart with Matplotlib
    Matplotlib is the standard python library for creating visualizations in Python. Pyplot is a module of Matplotlib library which is used to plot graphs and charts and also make changes in them. In this article, we are going to see how to draw a horizontal bar chart with Matplotlib. Creating a vertica
    2 min read
    Create a stacked bar plot in Matplotlib
    In this article, we will learn how to Create a stacked bar plot in Matplotlib. Let's discuss some concepts: Matplotlib is a tremendous visualization library in Python for 2D plots of arrays. Matplotlib may be a multi-platform data visualization library built on NumPy arrays and designed to figure wi
    3 min read
    Stacked Percentage Bar Plot In MatPlotLib
    A Stacked Percentage Bar Chart is a simple bar chart in the stacked form with a percentage of each subgroup in a group. Stacked bar plots represent different groups on the top of one another. The height of the bar depends on the resulting height of the combination of the results of the groups. It go
    3 min read
    Plotting back-to-back bar charts Matplotlib
    In this article, we will learn how to plot back-to-back bar charts in matplotlib in python. Let's discuss some concepts : Matplotlib: Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and d
    2 min read
    How to display the value of each bar in a bar chart using Matplotlib?
    Displaying the value of each bar in a bar chart using Matplotlib involves annotating the chart with numerical labels that represent the height of each bar. For example, if you have a bar with a height of 25, adding the label “25” on top of it helps readers quickly grasp the value. Let’s explore diff
    3 min read
    How To Annotate Bars in Barplot with Matplotlib in Python?
    Annotation means adding notes to a diagram stating what values do it represents. It often gets tiresome for the user to read the values from the graph when the graph is scaled down or is overly populated. In this article, we will discuss how to annotate the bar plots created in python using matplotl
    3 min read
    How to Annotate Bars in Grouped Barplot in Python?
    A Barplot is a graph that represents the relationship between a categoric and a numeric feature. Many rectangular bars correspond to each category of the categoric feature and the size of these bars represents the corresponding value. Using grouped bar plots,  we can study the relationship between m
    3 min read

    Histogram

    Plotting Histogram in Python using Matplotlib
    Histograms are a fundamental tool in data visualization, providing a graphical representation of the distribution of data. They are particularly useful for exploring continuous data, such as numerical measurements or sensor readings. This article will guide you through the process of Plot Histogram
    6 min read
    Create a cumulative histogram in Matplotlib
    The histogram is a graphical representation of data. We can represent any kind of numeric data in histogram format. In this article, We are going to see how to create a cumulative histogram in Matplotlib Cumulative frequency: Cumulative frequency analysis is the analysis of the frequency of occurren
    2 min read
    How to plot two histograms together in Matplotlib?
    Creating the histogram provides the visual representation of data distribution. By using a histogram we can represent a large amount of data and its frequency as one continuous plot.  How to plot a histogram using Matplotlib For creating the Histogram in Matplotlib we use hist() function which belon
    3 min read
    Overlapping Histograms with Matplotlib in Python
    Histograms are used to represent the frequencies across various intervals in a dataset. In this article, we will learn how to create overlapping histograms in Python using the Matplotlib library. The matplotlib.pyplot.hist() function will be used to plot these histograms so that we can compare diffe
    2 min read
    Bin Size in Matplotlib Histogram
    Bin size in a Matplotlib histogram controls how data is grouped into bins, each bin covers a value range and its height shows the count of data points in that range. Smaller bin sizes give more detailed distributions with many bins, while larger sizes produce fewer bins and a simpler view. For examp
    3 min read

    Scatter Plot

    Matplotlib Scatter
    Scatter plots are one of the most fundamental and powerful tools for visualizing relationships between two numerical variables. matplotlib.pyplot.scatter() plots points on a Cartesian plane defined by X and Y coordinates. Each point represents a data observation, allowing us to visually analyze how
    5 min read
    How to add a legend to a scatter plot in Matplotlib ?
    Adding a legend to a scatter plot in Matplotlib means providing clear labels that describe what each group of points represents. For example, if your scatter plot shows two datasets, adding a legend will display labels for each dataset, helping viewers interpret the plot correctly. We will explore s
    2 min read
    How to Connect Scatterplot Points With Line in Matplotlib?
    Prerequisite: Scatterplot using Seaborn in Python Scatterplot can be used with several semantic groupings which can help to understand well in a graph. They can plot two-dimensional graphics that can be enhanced by mapping up to three additional variables while using the semantics of hue, size, and
    2 min read
    How to create a Scatter Plot with several colors in Matplotlib?
    Matplotlib is a plotting library for creating static, animated, and interactive visualizations in Python. Matplotlib can be used in Python scripts, the Python and IPython shell, web application servers, and various graphical user interface toolkits like Tkinter, awxPython, etc. In this article, we w
    3 min read
    How to increase the size of scatter points in Matplotlib ?
    Prerequisites: Matplotlib Scatter plots are the data points on the graph between x-axis and y-axis in matplotlib library. The points in the graph look scattered, hence the plot is named as 'Scatter plot'. The points in the scatter plot are by default small if the optional parameters in the syntax ar
    2 min read

    Pie Chart

    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
    How to set border for wedges in Matplotlib pie chart?
    Pie charts can be used for relative comparison of data. Python offers several data visualization libraries to work with. The Matplotlib library offers different types of graphs and inbuild methods and properties to manipulate the graph. The wedges in the pie chart can be given a border using the wed
    3 min read
    Radially displace pie chart wedge in Matplotlib
    Pie charts are statistical graphs divided into slices that represent different data values and sum up to 100%. Python is one of the most popularly used programming languages for data visualization. Python has multiple data visualization libraries and Matplotlib is one of them. Matplotlib is widely u
    3 min read

    3D Plots

    Three-dimensional Plotting in Python using Matplotlib
    Visualizing data involving three variables often requires three-dimensional plotting to better understand complex relationships and patterns that two-dimensional plots cannot reveal. Python’s Matplotlib library, through its mpl_toolkits.mplot3d toolkit, provides powerful support for 3D visualization
    5 min read
    3D Scatter Plotting in Python using Matplotlib
    A 3D Scatter Plot is a mathematical diagram that visualizes data points in three dimensions, allowing us to observe relationships between three variables of a dataset. Matplotlib provides a built-in toolkit called mplot3d, which enables three-dimensional plotting. To create a 3D Scatter Plot, we use
    3 min read
    3D Surface plotting in Python using Matplotlib
    A Surface Plot is a representation of three-dimensional dataset. It describes a functional relationship between two independent variables X and Z and a designated dependent variable Y, rather than showing the individual data points. It is a companion plot of the contour plot. It is similar to the wi
    4 min read
    3D Wireframe plotting in Python using Matplotlib
    To create static, animated and interactive visualizations of data, we use the Matplotlib module in Python. The below programs will depict 3D wireframe. visualization of data in Python. In-order to visualize data using 3D wireframe we require some modules from matplotlib, mpl_toolkits and numpy libra
    1 min read
    3D Contour Plotting in Python using Matplotlib
    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. Let's look a
    2 min read
    Tri-Surface Plot in Python using Matplotlib
    A Tri-Surface Plot is a type of surface plot, created by triangulation of compact surfaces of finite number of triangles which cover the whole surface in a manner that each and every point on the surface is in triangle. The intersection of any two triangles results in void or a common edge or vertex
    2 min read
    Surface plots and Contour plots in Python
    Surface plots and contour plots are visualization tools used to represent three-dimensional data in two dimensions. They are commonly used in mathematics, engineering and data analysis to understand the relationships between three variables. In this article, we will understand about surface and cont
    3 min read
    How to change angle of 3D plot in Python?
    Prerequisites: Matplotlib, NumPy In this article, we will see how can we can view our graph from different angles, Here we use three different methods to plot our graph. Before starting let's see some basic concepts of the required module for this objective. Matplotlib is a multi-platform data visua
    3 min read
    How to animate 3D Graph using Matplotlib?
    Prerequisites: Matplotlib, NumPy Graphical representations are always easy to understand and are adopted and preferable before any written or verbal communication. With Matplotlib we can draw different types of Graphical data. In this article, we will try to understand, How can we create a beautiful
    4 min read

    Working with Images

    Working with Images in Python using Matplotlib
    Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack. Working with Images in Python using Matplotlib The image module in matplotlib library is
    3 min read
    Python | Working with PNG Images using Matplotlib
    Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack. It was introduced by John Hunter in the year 2002. One of the greatest benefits of visua
    3 min read
    How to Display an Image in Grayscale in Matplotlib?
    In this article, we are going to depict images using the Matplotlib module in grayscale representation using PIL, i.e. image representation using two colors only i.e. black and white. Syntax: matplotlib.pyplot.imshow(X, cmap=None) Displaying Grayscale image Displaying Grayscale image, store the imag
    2 min read
    Plot a Point or a Line on an Image with Matplotlib
    Prerequisites: Matplotlib Matplotlib and its constituents support a lot of functionality. One such functionality is that we can draw a line or a point on an image using Matplotlib in python. ApproachImport modulesRead the imagePlot the line or point on the imageDisplay the plot/image. Image Used: Im
    2 min read
    How to Draw Rectangle on Image in Matplotlib?
    Prerequisites: Matplotlib Given an image the task here is to draft a python program using matplotlib to draw a rectangle on it. Matplotlib comes handy with rectangle() function which can be used for our requirement. Syntax: Rectangle(xy, width, height, angle=0.0, **kwargs) Parameters: xy: Lower left
    2 min read
    How to Display an OpenCV image in Python with Matplotlib?
    The OpenCV module is an open-source computer vision and machine learning software library. It is a huge open-source library for computer vision, machine learning, and image processing. OpenCV supports a wide variety of programming languages like Python, C++, Java, etc. It can process images and vide
    2 min read
    Calculate the area of an image using Matplotlib
    Let us see how to calculate the area of an image in Python using Matplotlib.  Algorithm:  Import the matplotlib.pyplot module.Import an image using the imread() method.Use the shape attribute of the image to get the height and width of the image. It fetches the number of channels in the image.Calcul
    1 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