Info
此问题已关闭。 请重新打开它进行编辑或回答。
Overlap different axes on a 3d map
1 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I have the following 3d figure:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/196541/image.png)
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/196543/image.png)
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
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 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!