how to flip color in colorbar without changing the values?

8 visualizzazioni (ultimi 30 giorni)
colorbar
caxis([1 100]);
i want to make 100 = blue and 1 = red
thank you so much..
  2 Commenti
John Manalo
John Manalo il 12 Mag 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 il 12 Mag 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.

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 12 Mag 2015
oldcmap = colormap;
colormap( flipud(oldcmap) );
  3 Commenti
Walter Roberson
Walter Roberson il 12 Mag 2015
Please mark the Answer as Accepted then so the system knows it is solved.

Accedi per commentare.

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by