Pie Chart in MATLAB Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 1 Likes 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 P parasharraghav Follow 1 Improve P parasharraghav Follow 1 Improve Article Tags : Computer Subject Software Engineering MATLAB MATLAB Explore Software Engineering BasicsIntroduction to Software Engineering7 min readSoftware Development Life Cycle (SDLC)8 min readSoftware Quality - Software Engineering5 min readISO/IEC 9126 in Software Engineering4 min readBoehm's Software Quality Model4 min readSoftware Crisis - Software Engineering3 min readSoftware Measurement & MetricesSoftware Measurement and Metrics4 min readPeople Metrics and Process Metrics in Software Engineering7 min readHalsteadâs Software Metrics - Software Engineering10 min readCyclomatic Complexity6 min readFunctional Point (FP) Analysis - Software Engineering8 min readLines of Code (LOC) in Software Engineering4 min readSoftware Development Models & Agile MethodsWaterfall Model - Software Engineering12 min readWhat is Spiral Model in Software Engineering?9 min readPrototyping Model - Software Engineering7 min readIncremental Process Model - Software Engineering6 min readRapid Application Development Model (RAD) - Software Engineering9 min readCoupling and Cohesion - Software Engineering10 min readAgile Software Development - Software Engineering15+ min readSRS & SPMSoftware Requirement Specification (SRS) Format5 min readSoftware Engineering | Quality Characteristics of a good SRS7 min readSoftware Project Management (SPM) - Software Engineering8 min readCOCOMO Model - Software Engineering15+ min readCapability Maturity Model (CMM) - Software Engineering10 min readIntegrating Risk Management in SDLC | Set 18 min readSoftware Maintenance - Software Engineering13 min readTesting & DebuggingWhat is Software Testing?11 min readTypes of Software Testing15+ min readTesting Guidelines - Software Engineering3 min readWhat is Debugging in Software Engineering?11 min readVerification & ValidationVerification and Validation in Software Engineering6 min readRole of Verification and Validation (V&V) in SDLC5 min readRequirements Validation Techniques - Software Engineering8 min readPractice QuestionsTop 50+ Software Engineering Interview Questions and Answers15+ min read Like