How can I change the colormap for each tab in a tabbed figure?

조회 수: 5 (최근 30일)
Katie
Katie 2019년 10월 8일
답변: lvn 2019년 10월 9일
I am trying to create a tabbed figure where each of the two tabs has a different viewshed plotted on terrain using the mapping toolbox. I am able to create the tabbed figure, but I am unable to figure out how to use a different colormap on each tab. With the code below both of the tabs are using the colormap from the first tab (summer(2)). I've also been able to get both tabs to take on the colormap from the second tab (flipud(summer(2)) by not setting h1=axesm for the first tab and not setting h2=axesm for the second tab. Is there a way to set a different colormap for each tab of the figure?
figure(1);
tg=uitabgroup();
thistab=uitab(tg,'title','Terrain');
axes('Parent',thistab)
h1=axesm('globe','geoid',1.7365E+06);
meshm(viewshed,refmat,size(Z), Z);
axis tight
camposm(0,90,1e4)
camupm(90,0)
colormap(h1, summer(2))
shading interp
camlight
title('Terrain');
thistab=uitab(tg,'title','Visibility');
axes('Parent',thistab)
h2=axesm('globe','geoid',1.7365E+06);
hold on;
meshm(viewshed2,refmat,size(Z),Z);
axis tight
camposm(0,90,1e4)
camupm(90,0)
colormap(h2, flipud(summer(2)))
shading interp
camlight
title('Visibility 1');
Additional info: I'm running this code from app designer. Since mapping toolbox axes aren't well supported for UIAxes I'm trying to use tabbed figures to organize all the mapping toolbox based plots generated by my app.
Thank you in advance for the help!

채택된 답변

lvn
lvn 2019년 10월 9일
The code you gave didn't run on my PC because of a problem with viewshed. The following code runs and does not show the problem you mention (colorbars are different)
clear; close all; Z = 500*peaks(100);
refvec = [ 1000 0 0];
[lat1,lon1,lat2,lon2]=deal(-0.027,0.05,-0.093,0.042);
[visgrid,visleg] = viewshed(Z,refvec,lat1,lon1,100);figure(1);
tg=uitabgroup();
thistab=uitab(tg,'title','Terrain');
axes('Parent',thistab)
h1=axesm('globe','geoid',1.7365E+06);
meshm(visgrid,visleg,size(Z),Z);
axis tight
camposm(0,90,1e4)
camupm(90,0)
colormap(h1, summer(2)); colorbar;
shading interp
camlight
title('Terrain');
thistab=uitab(tg,'title','Visibility');
axes('Parent',thistab)
h2=axesm('globe','geoid',1.7365E+06);
hold on;
meshm(visgrid,visleg,size(Z),Z);
axis tight
camposm(0,90,1e4)
camupm(90,0)
colormap(h2, flipud(summer(2))); colorbar;
shading interp
camlight
title('Visibility 1');

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by