caxis with HeatMap?

조회 수: 13 (최근 30일)
D
D 2011년 7월 6일
I'd like to specify the scale of the colormap used for a heat map.
It seems that something like caxis would be appropriate but it doesn't appear to work. All of the examples are for functions like surf.
Is there a way to use caxis to do this, or something else that would work for a heat map?
Thanks very much.

채택된 답변

Patrick Kalita
Patrick Kalita 2011년 7월 6일
Maybe I should have mentioned this in the answer to your previous question, but maybe the HeatMap object's plot method would be useful here. That method will render the heatmap image into a standard MATLAB axes. Then you can use all the standard graphics functions like colorbar and caxis with it.
For example:
data = gallery('invhess',20);
hm = HeatMap(data);
ax = hm.plot; % 'ax' will be a handle to a standard MATLAB axes.
colorbar('Peer', ax); % Turn the colorbar on
caxis(ax, [-3 10]); % Adjust the color limits
  댓글 수: 2
D
D 2011년 7월 19일
Hello. This worked beautifully, in terms of what I asked. I have a few more questions, though, that I was hoping you might be able to answer.
Some of my labels on the heat map are getting cut off, and this seems arbitrary: i.e. the last letter of a shorter label is cut off, but the longer labels are fine. Is there a way to add extra space between the plot and the labels?
How do I title the figures directly, instead of the heat maps, without using the property editor?
Finally, there appears to be a lot of grey space surrounding the plot area in the figures. Is there a way to get rid of this, short of cropping?
Thanks again for your help.
D
D 2011년 7월 19일
Just to clarify: the extra grey space shows up when I try to resize the figure. The heat map expands a little, but most of the expansion in the figure window is the grey space.
Also, I have code for the title, but it does this strange thing where every part of the string is on a different line.
title(ax, ['Plot ' num2str(p) ': ' list(p)]);
where p is an index for this particular plot (I'm doing these in a loop) and where list = {'abcd'; 'efgh'}.
So, it should read something like: "Plot 1: abcd" and "Plot 2: efgh". Instead I get
Plot
1
:
abcd
At first, I thought this might be because the figure is too small, but after expanding the figure, the title didn't expand to the full length of the plot area.

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

추가 답변 (0개)

카테고리

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