caxis with HeatMap?

17 views (last 30 days)
D
D on 6 Jul 2011
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.

Accepted Answer

Patrick Kalita
Patrick Kalita on 6 Jul 2011
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 Comments
D
D on 19 Jul 2011
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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!