advanced Heatmap plotting question
Mostra commenti meno recenti
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!
Risposte (1)
Alan Stevens
il 21 Ago 2020
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 Commenti
Alan Stevens
il 21 Ago 2020
By looking from the top you get:

chang liu
il 21 Ago 2020
chang liu
il 21 Ago 2020
Alan Stevens
il 21 Ago 2020
Great!
chang liu
il 22 Ago 2020
Alan Stevens
il 22 Ago 2020
Try this:
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)
xlabel('x'), ylabel('y')
view(180,-90)
hold on
theta = zeros(360,1);
for i = 1:361; theta(i) = (i-1)*pi/180; end
r = 10; % You will have to decide this yourself
xc = r*cos(theta); yc = r*sin(theta);
plot(xc,yc)
chang liu
il 24 Ago 2020
chang liu
il 27 Ago 2020
Alan Stevens
il 27 Ago 2020
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).
chang liu
il 31 Ago 2020
Categorie
Scopri di più su Data Distribution Plots in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!