Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB -- How does one plot a heatmap from nxn matrix? [duplicate]

Tags:

plot

matlab

I have a 50x50 matrix with some numbers ranging from 0 to a bit over 1. How do I show a heatmap of this data with a colorbar? What I'm looking for is a plot where the x and y values range from 1 to 50 and 1 to 50, with each point (x, y) given a color corresponding to the size of the data at the matrix entry (x, y). For an example of such a heatmap, check out this amusing xkcd post.

Thanks!

like image 562
eqb Avatar asked Mar 28 '13 07:03

eqb


People also ask

How do you create a heatmap of a matrix in Matlab?

Create a matrix of data. Then create a heatmap of the matrix values. Use custom labels along the x-axis and y-axis by specifying the first two input arguments as the labels you want. Specify the title and axis labels by setting properties of the HeatmapChart object.

How do I show heatmap in Matlab?

Use the plot function to display the heatmap in another figure specified by the figure handle fH . fH = figure; hA = plot(hmo,fH); Use the returned axes handle hA to specify the axes properties.

How do you plot 3 dimensions in Matlab?

plot3( X , Y , Z ) plots coordinates in 3-D space. To plot a set of coordinates connected by line segments, specify X , Y , and Z as vectors of the same length. To plot multiple sets of coordinates on the same set of axes, specify at least one of X , Y , or Z as a matrix and the others as vectors.


1 Answers

What do you think about this example? see also?

>> A = randi([10,60],100,100);
>> colormap('hot')
>> imagesc(A)
>> colorbar

enter image description here

like image 197
0x90 Avatar answered Oct 02 '22 14:10

0x90