caxis with HeatMap?

15 visualizaciones (últimos 30 días)
D
D el 6 de Jul. de 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.

Respuesta aceptada

Patrick Kalita
Patrick Kalita el 6 de Jul. de 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 comentarios
D
D el 19 de Jul. de 2011
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 el 19 de Jul. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by