HeatMap - Maple Help

Statistics

 HeatMap
 generate heat maps

 Calling Sequence HeatMap(A, options, plotoptions)

Parameters

 A - data options - (optional) equation(s) of the form option=value where option is one of color, range, rowlabels, or columnlabels; specify options for generating the heat map plotoptions - options to be passed to the plots[display] command

Options

 The options argument can contain one or more of the options shown below. All unrecognized options will be passed to the plots[display] command. See plot/options for details.
 • color : list or range
 Specifies colors for the individual data sets. When a range of colors is given, the color associated with a datum is generated by interpolating between the two named colors based on the range of values in the data. For example if color=red..blue then the minimum values in the data will be red and the maximum values blue. If a list of colors is provided, the color associated with a datum is generated by interpolating uniformly through all named colors.
 • range : range, list of ranges, all, or bycolumn;
 The option range indicates that the data is to interpreted as being in a specified range and also controls whether the mapping from value to color is applied to each column independently or to the data as a whole.

 Option Coloring applies Meaning Example range=all To all data Same color range applied to all data, range inferred from data range=all range=a..b To all data Same explicit color range a..b applied to all data range=1..2 range=bycolumn Columnwise Each column has its own color range inferred from data range=bycolumn range=[a..b,c..d,...] Columnwise Each column has its own explicit color range range=[1..2,3..4]

 When ranges are inferred, the minimum data value and the maximum data value from the data are used. If a specified range is used and data values are outside of this range, they are truncated to nearest endpoint of the specified range.
 • columnlabels : list
 Specifies the labels corresponding to each column. The list can contain either strings or names.
 • rowlabels : list
 Specifies the labels corresponding to each row. The list can contain either strings or names.

Description

 • The HeatMap command generates a heat map for the specified data. A heat map is a method of data visualization representing the magnitude of included data as a discrete density plot.
 • The first parameter A is a numeric Matrix, a list of lists, or a DataFrame.

Examples

 > $\mathrm{with}\left(\mathrm{Statistics}\right):$

Generate a heat map for a random matrix.

 > $\mathrm{RM}≔\mathrm{LinearAlgebra}:-\mathrm{RandomMatrix}\left(10\right):$

The command to create the plot from the Plotting Guide using the data above is

 > $\mathrm{HeatMap}\left(\mathrm{RM}\right)$

Generate the same heat map, sampling colors from blue to white to red.

 > $\mathrm{HeatMap}\left(\mathrm{RM},\mathrm{color}=\left[\mathrm{blue},\mathrm{white},\mathrm{red}\right]\right)$

Generate visualization to compare the correlation between three data sets.

 > $U≔⟨\mathrm{seq}\left(0..10\right)⟩:$$V≔⟨\mathrm{seq}\left(\mathrm{sin}\left(i\right),i=0..10\right)⟩:$$W≔⟨\mathrm{seq}\left(\mathrm{cos}\left(i\right),i=0..10\right)⟩:$
 > $M≔\mathrm{Matrix}\left(\left[U,V,W\right]\right):$
 > $\mathrm{CM}≔\mathrm{CorrelationMatrix}\left(M,\mathrm{ignore}\right)$
 $\left[\begin{array}{ccc}1.0& -0.11674176508728776& -0.35424243510513426\\ -0.11674176508728776& 1.0& 0.07016628339426831\\ -0.35424243510513426& 0.07016628339426831& 1.0\end{array}\right]$ (1)
 > $\mathrm{HeatMap}\left(\mathrm{CM},\mathrm{columnlabels}=\left["n","sin\left(n\right)","cos\left(n\right)"\right],\mathrm{rowlabels}=\left["n","sin\left(n\right)","cos\left(n\right)"\right]\right)$

Compare intensities of absolute crime numbers for Canadian provinces.

 > $\mathrm{CanadaCrime}≔\mathrm{Import}\left("datasets/canada_crimes.csv",\mathrm{base}=\mathrm{datadir}\right):$
 > $\mathrm{Statistics}:-\mathrm{HeatMap}\left(\mathrm{CanadaCrime}\left[1..10,..\right],\mathrm{color}=\mathrm{white}..\mathrm{red},\mathrm{size}=\left[900,300\right]\right)$

Visualize the same crime statistics using the same color shading for all types of crime.

 > $\mathrm{Statistics}:-\mathrm{HeatMap}\left(\mathrm{CanadaCrime}\left[1..10,..\right],\mathrm{color}=\mathrm{white}..\mathrm{red},\mathrm{range}=\mathrm{all},\mathrm{size}=\left[900,300\right]\right)$

Compare the similarity of words for "water" in several languages using the Levenshtein distance.

 > $\mathrm{Words}≔\left["acqua","agua","eau","su","Wasser","water","woda","vatten","voda"\right]$
 ${\mathrm{Words}}{≔}\left[{"acqua"}{,}{"agua"}{,}{"eau"}{,}{"su"}{,}{"Wasser"}{,}{"water"}{,}{"woda"}{,}{"vatten"}{,}{"voda"}\right]$ (2)
 > $\mathrm{WordDistances}≔\mathrm{DataFrame}\left(\mathrm{Matrix}\left(\mathrm{numelems}\left(\mathrm{Words}\right),\left(i,j\right)↦\mathrm{StringTools}:-\mathrm{Levenshtein}\left(\mathrm{Words}\left[i\right],\mathrm{Words}\left[j\right]\right)\right),\mathrm{rows}=\mathrm{Words},\mathrm{columns}=\mathrm{Words}\right):$
 > $\mathrm{Statistics}:-\mathrm{HeatMap}\left(\mathrm{WordDistances},\mathrm{size}=\left[800,400\right],\mathrm{color}=\mathrm{blue}..\mathrm{white},\mathrm{range}=\mathrm{all}\right)$
 > 

Compatibility

 • The Statistics[HeatMap] command was introduced in Maple 2016.