how to flip color in colorbar without changing the values?

8 visualizaciones (últimos 30 días)
John Manalo
John Manalo el 12 de Mayo de 2015
Comentada: prio el 1 de Abr. de 2018
colorbar
caxis([1 100]);
i want to make 100 = blue and 1 = red
thank you so much..
  2 comentarios
John Manalo
John Manalo el 12 de Mayo de 2015
figure(1)
colorbar
caxis([10 100]);
fig=figure(1)
colorbar
mycmap = get(fig,'Colormap')
set(fig,'Colormap',flipud(mycmap))
this script does not work on large values like caxis([10 500]);
Walter Roberson
Walter Roberson el 12 de Mayo de 2015
I am not sure what you are saying. You appear to be attempting to alter caxis when there is existing graphics and expecting the existing graphics to stay the same. caxis changes the entire axis at the same time.
However, when you use colorbar() a new axis is created in versions before R2014b, and without doing a lot of checking I cannot be sure that it is paying attention to changes in the caxis of the original axes. I seem to recall stepping through it all years ago and finding that it set up a listener on the original axis properties. But what it used to do isn't too important if you are running R2014b or later as colorbar() now creates colorbar objects, and I have no idea how those are programmed.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Mayo de 2015
oldcmap = colormap;
colormap( flipud(oldcmap) );
  3 comentarios
Walter Roberson
Walter Roberson el 12 de Mayo de 2015
Please mark the Answer as Accepted then so the system knows it is solved.
prio
prio el 1 de Abr. de 2018
Thanks a lot for this answer!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Annotations 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