Info
This question is closed. Reopen it to edit or answer.
Overlap different axes on a 3d map
1 view (last 30 days)
Show older comments
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 Comment
Walter Roberson
on 20 Dec 2018
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.
Answers (1)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!