MATLAB Examples

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

Read about the heatmap function in the MATLAB documentation. This function is available in R2017a or newer.

For more examples, go to MATLAB Plot Gallery

% Check version
if verLessThan('matlab','9.2')
    error('heatmap is available in R2017a or newer.')
end

% Load ride data from Boston's bike sharing program
load CambridgeData cambridge

% Create a heatmap of DayOfWeek vs. AgeGroup, with color representing count
hm = heatmap(cambridge,'AgeGroup','DayOfWeek');

% Change the color to represent average Duration
hm.ColorVariable = 'Duration';
hm.ColorMethod = 'mean';