heatmap
statistics: heatmap (cdata)
statistics: heatmap (xvalues, yvalues, cdata)
statistics: heatmap (tbl, xvar, yvar)
statistics: heatmap (parent, …)
statistics: heatmap (…, Name, Value)
statistics: h = heatmap (…)
Heatmap of a matrix, or of the rows of a table counted or aggregated over two of its variables.
heatmap (cdata) draws the matrix cdata as a grid of
coloured cells, each carrying its value, with a colour bar beside them.
The columns are named '1', '2', …, and so are the
rows.
heatmap (xvalues, yvalues, cdata) names the columns
with xvalues and the rows with yvalues, vectors of distinct
numbers, text or categories with one element for each column and each row
of cdata.
heatmap (tbl, xvar, yvar) makes a column of each
distinct value of the table variable xvar and a row of each distinct
value of yvar, and colours each cell by the number of rows of
tbl falling in it. With 'ColorVariable' naming a numeric
variable, each cell holds the mean of that variable over its rows instead,
or what 'ColorMethod' asks for: 'count', 'mean',
'median', 'sum', 'min', 'max', or
'none' where each cell holds at most one row. The categories of a
categorical variable are taken in their order, those no row uses
included; numbers, text and logical values are sorted. A row whose
xvar or yvar is missing is left out.
heatmap (parent, …) places the heatmap in the figure or
panel parent rather than the current figure. The heatmap takes the
place of the current axes of its parent, and is refused where
hold is on for them.
heatmap (…, Name, Value) sets properties of the
heatmap; see stats.chart.HeatmapChart for all of them.
h = heatmap (…) returns the heatmap, a
stats.chart.HeatmapChart object, whose methods sortx,
sorty, xlim and ylim reorder and restrict its columns
and rows.
See also: stats.chart.HeatmapChart, imagesc, crosstab
Source Code: heatmap
A matrix as a heatmap: each cell carries its value and its colour.
heatmap (magic (5));
Columns and rows may be named, and the colours changed.
h = heatmap ({'Mon', 'Tue', 'Wed', 'Thu', 'Fri'}, {'am', 'pm'}, ...
[12, 15, 9, 20, 18; 7, 11, 14, 6, 9]);
h.Title = 'Calls answered';
h.Colormap = gray (64);
From a table: the cars of each origin and number of cylinders, and then their mean mileage.
load carsmall
t = table (categorical (cellstr (Origin)), Cylinders, MPG, ...
'VariableNames', {'Origin', 'Cylinders', 'MPG'});
subplot (1, 2, 1);
heatmap (t, 'Cylinders', 'Origin');
subplot (1, 2, 2);
heatmap (t, 'Cylinders', 'Origin', 'ColorVariable', 'MPG');