- The direction of the y-axis differs between heatmap and imagesc
- imagesc sorts the x and y values
Making a heat map from three vectors of different lengths
20 views (last 30 days)
I have a set of attached three vectors (x,y,z) of different dimensions where the x column is the independent coordinates for all the columns in y at 10 different values of z. I want to generate a heat map of x,y and z where the color bar would denote z-values.
Perhaps this answer was relevant https://www.mathworks.com/matlabcentral/answers/105390-making-a-heat-map-from-three-vectors
But it was erased from the database. Thanks!
Adam Danz on 14 Nov 2022
Edited: Adam Danz on 14 Nov 2022
In heatmap, XData define the number of columns and YData define the number of rows. Your matrix y is 21x10 meaning there will be 21 rows and 10 columns.
If you want there to be 10 rows and 21 columns,
heatmap(x,z,y'); % note the transpose on y
How to remove cell labels
The examples above do not show the cell labels because the axes are too small given the number of cells but to remove the cell labels,
h = heatmap(__)
h.CellLabelColor = 'none';
Another option is to use imagesc but note
Yet another alternative is to use histogram2.
% reproduce heatmap's colormap
cmap = [linspace(.9,0,n)', linspace(.9447,.447,n)', linspace(.9741,.741,n)'];