Heatmap of One Variable
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hey folks,
I hope you can help me with the issue attached to this question. I would like to create a heatmap that looks like the upper table in the attached picture.
Note: It is possible that Test1, Test2, Test3 and Test4 appear at the same time for one observation (Counter).
% inputData (lower table in the attached picture)
inputData = [1 0 0 0; 1 0 0 0; 1 1 1 0; 0 1 0 0; 0 0 1 0; 0 0 1 0; 0 0 1 1; 0 0 0 1];
Does anyone have an idea to achieve this?
0 commentaires
Réponses (1)
dpb
le 30 Juin 2020
xy=num2str([1:4].','Test%d');
data=[2 1 1 0;nan 1 0 0;nan nan 2 1;nan nan nan 1];
hHM=heatmap(xy,xy,data);
looks reasonably close...you may want to something about the default being black for the NaN.
3 commentaires
Steven Lord
le 1 Juil 2020
What are the rules for which rows in your data (the bottom table) should translate into which elements in the upper table? Most of them kind of make sense except for the orange row.
- Why doesn't that row contribute to the (1,1) element of the upper table?
- Why is element (2, 3) of the upper table not an orange 1 because the orange row in the lower table has 1 for both Test2 and Test3?
- And why isn't the lower triangular part of the upper table filled in?
If we know the rules of the game we may be able to help you play.
dpb
le 1 Juil 2020
Modifié(e) : dpb
le 1 Juil 2020
Yeah, I couldn't decipher how the two were specifically related, either. I just duplicated the figure.
Why "Test1-Test4" on the vertical labels I don't see any reason for -- the color coding (whatever it might mean) would seem the logical thing to use there.
But, one can spell "Fred" as "Jay, oh, e" and pronounce it as "Charles" if one defines the rules correctly.. Nobody else may be able to play the game then, but...
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!