필터 지우기
필터 지우기

how to make heatmap have a square-shape?

조회 수: 54 (최근 30일)
kinger
kinger 2019년 9월 13일
답변: Ramy Rabie 2020년 6월 6일
when I do
a=rand(4);
heatmap(a);
I got the following image:
untitled.jpg
How can I make the figure to a square-shaped one? I tried to use
axis equal;
but there's an error: Using axis with heatmap is not supported.
It seems that "axis" is not supported in heatmap.

채택된 답변

Shubh Sahu
Shubh Sahu 2019년 9월 17일
Hello Kinger,
heatmap does not support axis command directly but by extracting properties of heatmap, square-shaped figure can be made.
a=rand(4);
k=heatmap(a);
k.positions=[0.1300 0.1100 0.7179 0.179];
While using above code, make sure that Units property is set to normalized.
Regards,
Shubh
  댓글 수: 1
kinger
kinger 2020년 1월 17일
k.position instead of k.positions

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

추가 답변 (1개)

Ramy Rabie
Ramy Rabie 2020년 6월 6일
x = [zeros(11,1), 6*ones(11,1) , 137*ones(11,1) ,...
84*ones(11,1) ,9*ones(11,1) ,4*ones(11,1)]
y = [ ones(1,6) ; 4*ones(1,6) ; 45*ones(1,6) ;...
25*ones(1,6) ; 2*ones(1,6) ; 2*ones(1,6) ;...
13*ones(1,6) ; 52*ones(1,6) ; 58*ones(1,6) ;...
15*ones(1,6) ; 4*ones(1,6)]
% Making Heatmap figure has square tiles
wposX=100; wposY = 100;
heatmapLength = 500;
heatmapWidth = heatmapLength - (size(y,2)/size(y,1))*heatmapLength;
figure('Renderer', 'painters', 'Position', [wposX wposY heatmapWidth heatmapLength])
tempMap = heatmap(x+y);
% Make heatmap fill the figure
tempMap.InnerPosition = [0 0 1 1];

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by