Plot two plots in a 3d figure
1 view (last 30 days)
Show older comments
I am trying to put two plots of atmospheric kinetic energy into one figure that contains 3 axes. The axis sticking out of the screen would represent latitude, the axis going 'left-and-right' would be longitudes and the z-axis would be the height.
I would like to produce a 2D slice of kinetic energy into the latitude-height plane and another 2D slice of kinetic energy in the longitude-height plane. So basically, that would give two plots in the same figure. The data in which I am working with is the following:
Longitude and latitude coordinates are in separate matrices of 172x160 respectively (would later turn into meshgrids of 16x172 and 16x160)
Height coordinates is in a matrix of pressure coordinate 16x1 (would later turn into a meshgrid of 16x60)
The kinetic energy is within a 3d matrix of 172x160x16. Hence, a 2D slice of energy in the latitude-height plane would have the size of 16x160 because of the average in the longitude axes.
I made a small drawing in paint to show what it should like.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/195104/image.png)
I can do a 2D slice by itself, and it would something like this with the code and figure: (Note that I'm representing another form of energy, but the structure remains the same)
%%%%%Code : creating a single 2D slice along a latitude-axis
figure('color','white');
%Set pressure
Pres = [1000 975 950 925 900 850 800 700 600 500 400 300 250 200 150 100];
%Set grid for energy
x1 = 0;
x2 = 160;
ni = 160;
np = 16;
x_file = linspace(x1,x2,ni);
[x,p]=meshgrid(x_file,Pres);
%Set map
pcolor(x,p,Fld_LongAvg') %Where Fld_LongAvg' is the energy matrix (16x160)
hold on
shading interp
set(gca,'layer','top')
%Set y-axis (pressure axis)
set(gca,'yScale','log');
axis('ij')
set(gca,'ylim',[100 1000],'ytick',100:100:1000,'FontSize',18)
%Set x-axis (latitude axis)
set(gca,'Ygrid','on')
set(gca,'XTick',[0 160],'XtickLabel',{['Éq'],['N']})
%%%%%End of code
--> It has come to my attention that I don't even use the latitude coordinate matrix to set my x-axis, but I believe that would be for the best so that I could have proper x-ticks and labels. However, it appears unecessary to use that latitude coordinate matrix in order to get a proper plot.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/195106/image.png)
However, what I’m interested is to have both 2D slices together. Does anybody have any idea where to begin as I wasn't able to find documentation for this sort of task?
Answers (0)
See Also
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!