Heatmap of One Variable

6 次查看(过去 30 天)
Dario Walter
Dario Walter 2020-6-30
编辑: dpb 2020-7-1
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?

回答(1 个)

dpb
dpb 2020-6-30
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 个评论
Steven Lord
Steven Lord 2020-7-1
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 2020-7-1
编辑:dpb 2020-7-1
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...

请先登录,再进行评论。

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by