필터 지우기
필터 지우기

How to add top and bottom x-axes labels to a heatmap?

조회 수: 21 (최근 30일)
ct8
ct8 2023년 1월 12일
답변: Benjamin Kraus 2023년 12월 22일
I have a heatmap to which I want to add two x-axes, top and bottom, representing two different quantities. Attached are the .fig I got, and the source .mat.

채택된 답변

Benjamin Kraus
Benjamin Kraus 2023년 12월 22일
My answer from November 8, 2023 shows how to leverage tiledlayout to create an axes that sits under the heatmap and can be used to add additional labels. This same technique can be used to add duplicate labels on the top and bottom of the heatmap. It has working example code you can start with.

추가 답변 (1개)

Guilherme
Guilherme 2023년 1월 12일
It shows how to add two axes to a single plot. Then, you'd need to use xlabel and reference the Xaxis that you want to change as the target. You'd need something like that:
t = tiledlayout(1,1);
target_bottom = axes(t);
%%
% Plot Bottom
%%
target_top = axes(t);
target_top.XAxisLocation = 'top';
%%
% Plot Top
%%
xlabel(target_bottom,'Bottom Axis')
xlabel(target_top,'Top Axis')
  댓글 수: 1
ct8
ct8 2023년 1월 13일
I have tried this, but it is not working for my heat map. Essentially I want to know how to define the titled layout in my code which generates a heatmap.
figure()
imagesc(x,z,y')
% reproduce heatmap's colormap
n=256;
cmap = [linspace(.9,0,n)', linspace(.9447,.447,n)', linspace(.9741,.741,n)'];
colormap(cmap);
axis xy
colorbar()

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

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by