Borrar filtros
Borrar filtros

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

157 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Sanush
Sanush el 22 de Jul. de 2020
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 comentarios
Yanjika O
Yanjika O el 17 de Dic. de 2020
Hi, how can I move the title to the right side?
Sanush
Sanush el 22 de Dic. de 2020
Editada: Sanush el 22 de Dic. de 2020
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)

Iniciar sesión para comentar.

Más respuestas (2)

Rohan Kadambi
Rohan Kadambi el 12 de Dic. de 2023
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 el 27 de Oct. de 2017
[X,Y,Z] = peaks(100) ;
surf(X,Y,Z) ;
h = colorbar;
ylabel(h, 'My Colorbar')
  3 comentarios
Anthony Crockford
Anthony Crockford el 21 de Mzo. de 2019
Also looking for a solution ... no luck so far.
arnold
arnold el 4 de Abr. de 2019
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Data Distribution Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by