MATLAB Answers

Reverse/flip values in the colorbar axis

7 views (last 30 days)
Turbulence Analysis
Turbulence Analysis on 15 Oct 2020
Commented: Bjorn Gustavsson on 15 Oct 2020
Hi,
In the attached figure, I have reverse the values in the color bar i.e. red to be positive and blue to be negative. Please help me with this. I have tried flipud, but it changes the color pattern in the contour.

  0 Comments

Sign in to comment.

Answers (1)

Bjorn Gustavsson
Bjorn Gustavsson on 15 Oct 2020
Edited: Bjorn Gustavsson on 15 Oct 2020
If you want exactly that colormap, but flip it you can do this:
cmp = colormap;
cmp = flipud(cmp);
colormap(cmp);
You should be able to re-set the colormap to jet in one call:
colormap(jet)
HTH

  2 Comments

Turbulence Analysis
Turbulence Analysis on 15 Oct 2020
Hi,
Nothing been changed. I am getting exactly the same..
Bjorn Gustavsson
Bjorn Gustavsson on 15 Oct 2020
In that case your colormap is made in some other fashion than with the built-in colorbar command. This should show that my suggestion works:
imagesc(peaks(123))
colorbar;
pause(1)
cmp = colormap;
cmp = flipud(cmp);
colormap(cmp)

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!