how to flip color in colorbar without changing the values?

조회 수: 9 (최근 30일)
John Manalo
John Manalo 2015년 5월 12일
댓글: prio 2018년 4월 1일
colorbar
caxis([1 100]);
i want to make 100 = blue and 1 = red
thank you so much..
  댓글 수: 2
John Manalo
John Manalo 2015년 5월 12일
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 2015년 5월 12일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2015년 5월 12일
oldcmap = colormap;
colormap( flipud(oldcmap) );
  댓글 수: 3
Walter Roberson
Walter Roberson 2015년 5월 12일
Please mark the Answer as Accepted then so the system knows it is solved.
prio
prio 2018년 4월 1일
Thanks a lot for this answer!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by