How do I save a colormap and use it for another figure?

조회 수: 43 (최근 30일)
Alex
Alex 2019년 3월 31일
댓글: Star Strider 2019년 4월 2일
I run a script and produce the following figure.
AIS_asia_15plane_raw.jpg
I use colormapeditor to adjust the scale (see colorbar near 0 and 1). When I do the same for another figure that has the same range of values (0 to 1) the colorbar is slightly different (0.7 is yellow in the top figure and greenish in the bottom figure):
AIS_asia_45plane_raw.jpg
How do I save the colormap from the first figure and apply it to another?
Thank you in advance for your help!
Best regards,
Alex

채택된 답변

Star Strider
Star Strider 2019년 3월 31일
After you plot the first figure, use this get call:
cm = get(gca,'Colormap');
Note that the 'Colormap' (link) and the colorbar (link) object are not the same. If you want to save it and use it somewhere else, you can get its handle with:
c = colorbar;
Experiment to get the result you want.
  댓글 수: 8
Alex
Alex 2019년 4월 2일
I hope I get points for originality. This works great. Thank you for your time and patience! I suppose that is usually the problem with computers...the user.
Me: "The computer isn't doing what I'm telling it to do."
Answer: "The computer is doing exactly what you are telling it to do! The problem is what you are telling it to do is different than what you think you are telling it to do."
Star Strider
Star Strider 2019년 4월 2일
As always, my pleasure!
I learned something from figuring out the problem you were having, and the solution, as well.
Your comment reminds me of a poem posted to the Stanford University computer bulletin board in the late 1970s:
I really hate this damn machine.
I wish that they would sell it.
It won’t do what I want it to,
But only what I tell it!

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by