title string on vertical colorbar

197 visualizaciones (últimos 30 días)
Leslie
Leslie el 8 de Jul. de 2011
Comentada: Brice Arthur Azangue el 12 de Jun. de 2023
I want to put a colorbar to the right of a plot; fortunately, MATLAB wants to do that too, so a plain call to colorbar works. However, I'd also like to put a readable title on the colorbar to identify the plotted variable & its units. I tried this
h = colorbar;
set(get(h,'title'),'string','ISCCP Daytime Sc Amount (%)');
MATLAB wants to put this above the colorbar (!) where it runs into the plot title. I can rotate the text
h = colorbar;
set(get(h,'title'),'string','ISCCP Daytime Sc Amount (%)','Rotation',90.0);
but it's still centered up above the vertical colorbar. Trying to calculate a position for it in colorbar-relative coordinates is a real pain. Is there another way to correctly position this metadata alongside the colorbar?
  1 comentario
KEVIIN CHRISTOPHER CORDOVIZ
KEVIIN CHRISTOPHER CORDOVIZ el 30 de En. de 2018
Editada: Rik el 18 de Feb. de 2020
Simple Solution for this.
h = colorbar;
set(get(h,'label'),'string','ISCCP Daytime Sc Amount (%)');
That way, it will no longer be on top of the colorbar but beside it. :)

Iniciar sesión para comentar.

Respuestas (2)

Patrick Kalita
Patrick Kalita el 8 de Jul. de 2011
This is kind of hack, but how about this:
h = colorbar;
ylabel(h, 'foo')
  6 comentarios
Daniyal Altaf Baloch
Daniyal Altaf Baloch el 7 de Feb. de 2020
You saved us. Good answer
Brice Arthur Azangue
Brice Arthur Azangue el 12 de Jun. de 2023
thanks for this code

Iniciar sesión para comentar.


Sara Soufsaf
Sara Soufsaf el 9 de Abr. de 2022
To update Patrick Kalita's answer
h = colorbar;
title(h, 'foo')

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by