MATLAB Examples

This is an example of how to create a simple pie chart in MATLAB®.

Read about the pie function in the MATLAB documentation.

For more examples, go to MATLAB Plot Gallery

% Load the data for US population by age 1860-2000
load populationAge population groups

% Get the population for each age group for the year 2000
age2000 = population(15, :);

% Create a pie chart using the pie function -- use age groups as labels
figure
pie(age2000, groups)

% Add title
title('US population by age for the year 2000')