Overlay curves over heatmap

조회 수: 49 (최근 30일)
or ohev shalom
or ohev shalom 2019년 12월 25일
댓글: MJ 2022년 10월 5일
Hello everyone,
I was wondering if it is possible to plot curves over heatmap. It goes something like this:
X = 20:20:1000;
Y = 100:-2:1;
Z = randi(100,50,50);
h = heatmap(X,Y,Z);
hold on
for ii=1:5
curve = ii+1000./X;
plot(X, curve)
end
hold off
I want the curves to be above the heatmap. For example, in the figures below,Capture.PNG
the right figure should be on top of the left figure.
Any ideas?
Thanks in advance!

채택된 답변

Akira Agata
Akira Agata 2019년 12월 26일
How about the following way?
  1. Plot the heatmap
  2. Add axes over the heatmap
  3. Plot lines on the axes
  4. Set the background color of the axes to 'none'
  5. Adjust the axes size to fit to the heatmap
The following is an example.
% Sample data
cdata = [45 60 32; 43 54 76; 32 94 68; 23 95 58];
figure
heatmap(cdata)
colorbar
ax = axes;
plot(ax,magic(4),'LineWidth',2)
ax.Color = 'none';
% Maybe it needs some adjustment, like:
ax.Position(3) = 0.72;
ax.XTick = [];
ax.YTick = [];
untitled.png
  댓글 수: 3
Chamila Siyamalapitiya
Chamila Siyamalapitiya 2021년 8월 24일
How to apply this concept for subplot? when use ax = axes, it use the whole space, not the subplot space
MJ
MJ 2022년 10월 5일
Same question about subplot...

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by