advanced Heatmap plotting question
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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!
0 commentaires
Réponses (1)
Alan Stevens
le 21 Août 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 commentaires
Alan Stevens
le 27 Août 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).
Voir également
Catégories
En savoir plus sur Data Distribution Plots dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
