MATLAB Examples

This is an example of how to create an area plot in MATLAB®.

Read about the area function in the MATLAB documentation.

For more examples, go to MATLAB Plot Gallery

% Load population data
load PopulationAge years population groups

% Create the area plot using the area function
area(years, population/1000000)
colormap winter

% Add a legend
legend(groups, 'Location', 'NorthWest')

% Add title and axis labels
title('US Population by Age (1860 - 2000)')
ylabel('Population in Millions')