MATLAB Examples

This is an example of how to create an exploded 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 South American populations
load SouthAmericaPopulations populations countries

% Calculate the total populations and percentage by country
total = sum(populations);
percent = populations/total;

% Create a pie chart with sections 3 and 6 exploded
explode = [0 0 1 0 0 1 0 0];
pie(percent, explode, countries)

% Add title
title('South American Population by Country')