How do I prevent all my axes colormaps in a figure from being updated at once?

조회 수: 6 (최근 30일)
Folks,
I have a single GUI with several axes. When I set the current axes to axes 1, and I change the colormap with "colormap(gray)" for example, this changes the colorbars on the other axes to also be gray. My desired behavior is to control each axes colormap within my GUI indepdently. I tried the Matlab uploaded functions "freezeColors" and "unfreezeColors", but that does not seem to fix this.
Thank you,
Kris

채택된 답변

Stephen23
Stephen23 2019년 5월 31일
편집: Stephen23 2019년 5월 31일
According to the colormap documentation the syntax that you are using changes the colormap for the entire figure, which is inherited by any axes within that figure. The documentation also states that if you only want to change the colormap of one axes then you need to specify those axes:
axh = axes(...)
...
colormap(axh,...)
Tip: experienced MATLAB users recommend always using explicit graphics handles, as my example code shows, rather than unreliable and unpredictable gca, gcf, etc.
  댓글 수: 1
Kristoffer Walker
Kristoffer Walker 2019년 5월 31일
Thanks for the reply, Stephen. I tried that earlier and it avoided updating the colorbars of axes1 and 2, but it still did not touch axes4. But the issue must have been a stale instance of the GUI figure window when I previously was using "freezeColors" functionality. I restarted the GUI and explicitly passes the axes handles and now it all works. Thanks again.
Kris

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

추가 답변 (1개)

Kristoffer Walker
Kristoffer Walker 2019년 5월 31일
So if I step through, this clearly does not work in one of my guide-generated GUI callbacks:
axes(handles.axes4);
imagesc(data); axis xy;
colormap(jet)
If I step through it, when I get to the colormap function, I can substitute any colormap and run it at the keyboard, and it has no effect. Something has frozen the axes4 image from updating its colormap. However, this above code will change axes1 and axes2 colorbars. I have removed all instances of freezeColors/unfreezeColors calls to avoid any influences from that 3rd party software. Again, I am on 2017a. I hear so much about how this was all fixed back in 2014 in these boards, but that does not seem to be my perspective.
Kris

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by