Here is an example code to create a heatmap with categorical and quantitative color scales using MATLAB:
main.m694 chars25 lines
In this example code, data
is the matrix storing the data to be plotted, categories
is an array of category labels corresponding to the rows of data
, quantiles
are the quartiles of data
, which will be used to set the limits of the color axis.
The colormap
in this example uses 5 colors to represent each of the 4 categories and a white color for missing values. The caxis
function is used to set the limits of the color scale to be slightly larger than the minimum and maximum values of data
. The colorbar
function adds a color scale legend to the plot. The xticklabels
and yticklabels
functions add labels to the x and y axes respectively. Finally, the for
loop is used to add text annotations to each data point in the heatmap.
This will result in a heatmap with a categorical color scale for the rows of data, and a quantitative color scale for the actual data values.
gistlibby LogSnag