필터 지우기
필터 지우기

Label the color bar for a heat map created with heatmap(x,y,data)

조회 수: 156 (최근 30일)
Jose Zamora Zeledon
Jose Zamora Zeledon 2017년 10월 26일
답변: Rohan Kadambi 2023년 12월 12일
How can I label the color bar (e.g. 'Pressure (Pa)' or 'Temperature (K)') for a heat map created with h = heatmap(x,y,data)? I don't see a colorbar handle or property in h.

채택된 답변

Sanush
Sanush 2020년 7월 22일
dat = rand(5);
heatmap(dat)
annotation('textarrow',[1,1],[0.5,0.5],'string','My Text', ...
'HeadStyle','none','LineStyle','none','HorizontalAlignment','center','TextRotation',90);
  댓글 수: 2
Yanjika O
Yanjika O 2020년 12월 17일
Hi, how can I move the title to the right side?
Sanush
Sanush 2020년 12월 22일
편집: Sanush 2020년 12월 22일
Its already on the right. Unless your figure window is too small. Try resizing it.
set(gcf, 'Position', get(0,'Screensize'));
Alternatively, you can manually edit the location after plotting
plotedit(gcf)

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

추가 답변 (2개)

Rohan Kadambi
Rohan Kadambi 2023년 12월 12일
You can reveal hidden properties of handle objects by casting them to struct. Doing this to the HeatMapChart handle reveals a handle to the colorbar:
h = heatmap(rand(10));
hs = struct(h);
Warning: Calling STRUCT on an object prevents the object from hiding its implementation details and should thus be avoided. Use DISP or DISPLAY to see the visible public details of an object. See 'help struct' for more information.
ylabel(hs.Colorbar, "Colorbar Label");

KSSV
KSSV 2017년 10월 27일
[X,Y,Z] = peaks(100) ;
surf(X,Y,Z) ;
h = colorbar;
ylabel(h, 'My Colorbar')
  댓글 수: 3
Anthony Crockford
Anthony Crockford 2019년 3월 21일
Also looking for a solution ... no luck so far.
arnold
arnold 2019년 4월 4일
I am looking for the same. I'd appreciate any hint to get around this problem.
I was really happy to see them introduce the heatmap function but it again is quite inconsistent with the rest. I can't get a handle on the colorbar label to set the string like one usually can. Really annoying for the diagram tools to be so inconsistent still, I thought this was gonna go away when they changed it some years ago.

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

카테고리

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