Heatmap of One Variable

5 Ansichten (letzte 30 Tage)
Dario Walter
Dario Walter am 30 Jun. 2020
Bearbeitet: dpb am 1 Jul. 2020
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?

Antworten (1)

dpb
dpb am 30 Jun. 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 Kommentare
Steven Lord
Steven Lord am 1 Jul. 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
dpb am 1 Jul. 2020
Bearbeitet: dpb am 1 Jul. 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...

Melden Sie sich an, um zu kommentieren.

Tags

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by