advanced Heatmap plotting question

6 次查看(过去 30 天)
chang liu
chang liu 2020-8-21
评论: chang liu 2020-8-31
hi matlab experts, i have the following data matrix (see attached data.mat file)
i don't care about the all 0 column.
first column is x coordinate, second is y coordinate.
4th column is the value
as you can tell this is some sort of a scan that covers a 30x30 xy area
so for example, the first row of this data is -15,-15,0, 2921. it means, at x= -15 and y= -15, the data value is 2921 (ignore the 0)
question:
1) how do you plot a simple heatmap using this data?
2) more difficult: i really care about the values that are less than 3000. for me, any value less than 3000 means 'valid', any value above 3000 is invalid. so in addition to a normal heatmap that will just display the values in a temperature sense (like from cool to hot) , i really want another graph that clearly shows me what areas are 'valid' and what areas are 'invalid' in a black and white color sense (or green/red, whatever, as long as its just two colors) . one that i could easily look at and say, hey, at x=5 y=5, the value is invalid (above 3000)
thanks a lot!

回答(1 个)

Alan Stevens
Alan Stevens 2020-8-21
The following will do it, though there are probably neater ways to do the colouring:
load('data.mat')
x = Z0(:,1); y = Z0(:,2); z = Z0(:,4);
x = reshape(x,31,31); y = reshape(y,31,31);z=reshape(z,31,31);
zlo = z<=3000;
C = 100*zlo;
surf(x,y,z,C)
  10 个评论
Alan Stevens
Alan Stevens 2020-8-27
If you add the colormap command just before the surf command like so:
...
C = 100*zlo;
colormap([0 0 0; 1 1 1]);
surf(x,y,z,C)
...
you will just get two colours (or just one for some situations!) .
The colormap above will result in black (the [0 0 0]) and white (the [1 1 1])..
By changing the values in the second row (i.e. the [1 1 1] values) you can adjust the colour (each of the digits must be between 0 and 1: they are RGB values). For example [127/255 1 212/255] is aquamarine (I can't think what yellow is off the top of my head).

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by