Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Overlap different axes on a 3d map

조회 수: 1 (최근 30일)
Sebby RedRice
Sebby RedRice 2018년 11월 24일
마감: Walter Roberson 2018년 12월 20일
Hello everyone,
I have the following 3d figure:
This figure shows the north American boundaries (blue lines) along with surface temperature (colorbar, in kelvins) and geopotential height (the 3d mesh in dark blue, in decameters). After much trial and error, I was able to get this figure by doing the following code. I plotted temperature by using surf, the domain by using axesm and the geopotential height by using surface.
figure('rend','painters','pos',[500 500 1000 800])
%1) Add temperature profile
TTsurf = surf(yy_grid,xx_grid,zeros(size(yy_grid)),Temperature_map); %Size 172x160
set(TTsurf,'FaceColor','interp','EdgeColor','interp')
colorbar
caxis([200 300]);
hold on
%2 Prepare domain map
%Coordinates were obtained from a file
axesm('MapProjection','eqdcylin','Origin',[Grd_xlat1 Grd_xlon1 90-az],...
'FLonLimit',[lon1 lon2],'FLatLimit',[lat2 lat1],...
'FFill',400,'MeridianLabel','on',...
'ParallelLabel','on','MLabelParallel','south','Aspect','normal')
axis on
coast = load ('coast.mat');
geoshow(coast.lat,coast.long,'LineWidth',1)
tightmap
view(3)
zlim([0 1])
%3) Add geopotential height
GZsurf = surface(xx_grid,yy_grid,Geopotential_height);
set(GZsurf,'FaceColor','interp','EdgeColor','interp');
GZsurf.FaceAlpha = 0.5;
However, I would like my geopotential height mesh to have it's own colorbar. What currently happens is that this geopotential height acquires its dark blue color by the temperature colorbar. To create two colorbars (or rather, two axes), I read through the following post : https://www.mathworks.com/matlabcentral/answers/101346-how-do-i-use-multiple-colormaps-in-a-single-figure and concluded that the method I should try to follow is the example #5 (last method). As such, I arrive with the following code:
figure('rend','painters','pos',[500 500 1000 800])
%1) Add temperature profile
hAxesTT = axes;
axis(hAxesTT,'off')
colormap(hAxesTT,jet);
TTsurf = surf(yy_grid,xx_grid,zeros(size(yy_grid)),Temperature_map);
set(TTsurf,'FaceColor','interp','EdgeColor','interp')
colorbar
caxis([200 300]);
hold on
%2) Prepare domain map
axesm('MapProjection','eqdcylin','Origin',[Grd_xlat1 Grd_xlon1 90-az],...
'FLonLimit',[lon1 lon2],'FLatLimit',[lat2 lat1],...
'FFill',400,'MeridianLabel','on',...
'ParallelLabel','on','MLabelParallel','south','Aspect','normal')
axis on
coast = load ('coast.mat');
geoshow(coast.lat,coast.long,'LineWidth',1)
tightmap
view(3)
zlim([0 1])
%3) Add geopotential height
hAxesGZ = axes;
axis(hAxesGZ,'off')
colormap(hAxesGZ,cool);
GZsurf = surface(xx_grid,yy_grid,Geopotential_height);
set(GZsurf,'FaceColor','interp','EdgeColor','interp');
GZsurf.FaceAlpha = 0.5;
view(3)
This is a good improvement, but now it appears as though my geopotential height is no longer aligned with the rest of the domain and I don't know how to fix that.
Would anybody have any suggestions on how I should proceed? If anybody needs me to create a set of data in order for them to try it out, just ask in the comments and i'll edit the post.
Thank you,
  댓글 수: 1
Walter Roberson
Walter Roberson 2018년 12월 20일
This Question was answered by the original poster, and closed by the original poster, who could have just deleted the question instead of posting a solution. The closing was thus within policy. However, I would like to recommend to the author to re-open it so that other people can learn from the question and the effort the author put into solving it.

답변 (1개)

Sebby RedRice
Sebby RedRice 2018년 11월 25일
편집: Sebby RedRice 2018년 11월 25일
Alright I got it for those who want to know. I had to change quite a few things.
figure('rend','painters','pos',[300 400 1200 900])
%Add temperature profile as color
hAxesTT = axes();
TTsurf = surf(xx_grid,yy_grid,zeros(size(yy_grid)),Temperature_map);
set(TTsurf,'FaceColor','interp','EdgeColor','interp')
colorbar
caxis([200 300]);
hold on
%Add sea level pressure
contour(x(:,:,1), y(:,:,1), Valeur_p(:,:,1), 'LineWidth',2,'color','k');
%Prepare domain map
domain_map='NA_0.44_large';
axesm('MapProjection','eqdcylin','Origin',[Grd_xlat1 Grd_xlon1 90-az],...
'FLonLimit',[lon1 lon2],'FLatLimit',[lat2 lat1],...
'FFill',400,'MeridianLabel','on',...
'ParallelLabel','on','MLabelParallel','south','Aspect','normal')
axis on
coast = load ('coast.mat');
geoshow(coast.lat,coast.long,'LineWidth',1)
tightmap
%Workout on the layout
view(3)
zlim([0 1.5])
view([270+45 20])
%Prepare GZ axis
hAxesGZ = axes('view',hAxesTT.View);
axis equal
axis tight
set([hAxesTT,hAxesGZ],'Position',[.17 .11 .685 .815]); %Give both axes the same position
axis(hAxesGZ, [-.5210477249644113 .6341078853350113 -.582532959384541 .6588038476966931 0 1.5]) %Modify the 2nd axes in order for it to have the same position as the 1st axis. This can be figured out by going unto the grap editor
hold on %Pretty important.
view([270+45 20])
colormap(hAxesGZ,cool);
%Plot GZ
GZsurf = surf(xx_grid,yy_grid,Geopotential_height);
set(GZsurf,'FaceColor','interp','EdgeColor','interp');
GZsurf.FaceAlpha = 0.5;
hAxesGZ.Visible = 'off';

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by