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...

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by