Pie Chart in MATLAB Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report A Pie chart is a circular graph that is divided into sections and each section represents the proportionate part of the whole. In MATLAB we have a function named pie() which allows us to plot a bar graph. Syntax:pie(X)pie(X) draws a pie chart using the data in X. Each slice of the pie chart represents an element in X.Where the sum(X) ≤ 1, then the areas of the pie slices directly specify the values in X pie draws only a partial pie if sum(X) < 1.Where the sum(X) > 1, then the area of each slice of the pie is determined by pie normalizes the values by X/sum(X)Here let X be a categorical data type, the slices correspond to categories. The number of elements in the category divided by the number of elements in X becomes The area of each slice.Now let's move to some examples.Example 1: A simple pie chart: MATLAB % data b= [20 30 40 30] % pie function to draw pie chart pie(b) Output :fig 1: Pie chartExample 2: Pie chart with offset: MATLAB % data b= [20 30 40 30] % offset first and third by using 1 at explode explode = [1 0 1 0] % pie function to draw pie chart with % explode 1st and 3rd position data pie(b,explode) Output :fig 2: Pie chart with offsetExample 3: Pie chart with labels: MATLAB % data b= [20 30 40 30] % labelling on Pie chart labels={'a','b','c','d'} % pie function to draw pie chart with labels pie(b,labels) Output :fig 3: Pie chart with labelsExample 4: Partial Pie chart: MATLAB % create vector whose sum is less than 1 b= [0.2 0.4 0.1] % pie function to draw pie chart pie(b) Output : fig 4: Partial Pie chartExample 5: Compare 2 pie charts: MATLAB % data b= [20 30 40 30] a= [10 40 20 20] % labelling on pie chart labels={'a','b','c','d'} % to add more than 1 plot in same figure t = tiledlayout(1,2,'TileSpacing','compact'); % create pie charts ax1 = nexttile; pie(ax1,a) title('Pie chart 1') ax2 = nexttile; pie(ax2,b) title('Pie chart 2') % create legend and put labels as arguments lgd = legend(labels); % position of legend there are 4 positions %'north','south','east','west' lgd.Layout.Tile = 'north'; Output : fig 5: Comparison of 2 pie charts Comment More infoAdvertise with us Next Article MATLAB - Plots in Detail P parasharraghav Follow Improve Article Tags : Computer Subject Software Engineering MATLAB MATLAB Similar Reads Nested Pie Chart in R In this article, we will discuss how to create a nested pie chart in the R Programming Language.A Pie Chart is a circular plot that can display only one series of data. The area of slices of the pie represents the ratio of the parts of the data that are visualized by that slice. But sometimes we nee 4 min read Pie Chart Pie chart is a popular and visually intuitive tool used in data representation, making complex information easier to understand at a glance. This circular graph divides data into slices, each representing a proportion of the whole, allowing for a clear comparison of different categories making it ea 11 min read Simple GUI Calculator in MATLAB MATLAB is a powerful programming language that makes working with different mathematical equations easier. It is widely preferred by engineers and scientists. In this article, we will see, how to build a GUI-based simple calculator in MATLAB, which will take input and will return a value. So let's g 3 min read MATLAB - Plots in Detail Prerequisite: Introduction to MATLABMATLAB is a powerful programming language, that can be used to draw various plots used in machine learning, deep learning, computer vision, and big data programming. Let us start with coding for plots in MATLAB. Example 1: Let us first understand the simple plot 2 min read Scatter Plot in MATLAB Scatter Plot is a popular type of graph plot that plots pairs of coordinate points discretely rather than continuously. These plots are extensively used in various industries such as the data science industry because of their statistical importance in visualizing vast datasets. Scatter Plots in MAT 3 min read Simulink in MATLAB MATLAB which is also known as "Matrix Laboratory" allows its user to manipulate matrixes, plotting of functions and data, creation of algorithms, and user interfaces written in different programming languages by providing a computing environment. MATLAB is software designed and powered by mathworks. 4 min read Like