Multiple 2D contour plots in a single 3D plot
Ältere Kommentare anzeigen
Please I want the 2D contour plots to be arranged along either the X or Y axis. That is, the Z-axis of 45, 75, and 90 should rather be placed in either the X or Y-axis.
Kindly see the code I'm currently using below. Thank you
[y,x] = meshgrid(2:1:8,0:2.5:7.5);
Z1=All_CL(:,1:4)';
Z2=All_CL(:,5:8)';
Z3=All_CL(:,9:12)';
set(gcf,'position',[10,50,605,396]);
set(gca,'position',[0.15 0.25 0.8 0.60],'fontname','times new roman','fontsize',20);
set(gca,'xtick',0:2.5:7.5,'ytick',2:1:8,'ztick',30:15:90,'clipping','off');
[~,h] = contourf(x,y,Z1,25,'edgecolor','none'); % plot contour at the bottom
h.ContourZLevel = 90;
[~,h] = contourf(x,y,Z2,25,'edgecolor','none'); % plot contour at the bottom
h.ContourZLevel = 75;
[~,h] = contourf(x,y,Z3,25,'edgecolor','none'); % plot contour at the bottom
h.ContourZLevel = 45;
colormap(jet)
hcb=colorbar;
hold off
view(3)
camup([0 0 0])
zlim([30 90]);
caxis([0.05 2])
Antworten (1)
Shubham Rawat
am 26 Mär. 2021
0 Stimmen
Hi,
As per my understanding, you will not be able to do this. There is no Property as such.
You are plotting contour on XY axis so its Z axis is empty. Now you want to fill that with some value "h.ContourZLevel", which is the height of that plot.
But if you want to change X or Y values, it is not valid to change existing values of Data.
Hope this Helps!
7 Kommentare
Reynolds Addo-Akoto
am 29 Mär. 2021
Shubham Rawat
am 29 Mär. 2021
Hi,
Yes that value will be of the remaining axis value. e.g. if you are making contour on xz axis then the "h.ContourZLevel" value will be of y axis.
Reynolds Addo-Akoto
am 31 Mär. 2021
Shubham Rawat
am 31 Mär. 2021
Hi,
Simply change the parameters in the contour function:
For Example:
[~,h] = contourf(x,y,Z1,25,'edgecolor','none'); %this is for xy axis
[~,h] = contourf(x,Z1,y,25,'edgecolor','none'); %this is for xZ1 axis
Hope this helps!
Reynolds Addo-Akoto
am 31 Mär. 2021
Shubham Rawat
am 31 Mär. 2021
Hi,
x = linspace(-2*pi,2*pi);
y = linspace(0,4*pi);
[X,Y] = meshgrid(x,y);
Z1 = sin(X) + cos(Y);
Z2 = cos(X) + cos(Y);
Z3 = sin(X) + sin(Y);
[~,h] = contourf(x,y,Z1,25,'edgecolor','none'); % plot contour at the bottom
h.ContourZLevel = 90;
hold on
[~,h] = contourf(x,y,Z2,25,'edgecolor','none'); % plot contour at the bottom
h.ContourZLevel = 75;
hold on
[~,h] = contourf(x,y,Z3,25,'edgecolor','none'); % plot contour at the bottom
h.ContourZLevel = 45;
view(3)
camup([-1 0 0]); %rotate axis
Hope this helps!
Reynolds Addo-Akoto
am 1 Apr. 2021
Kategorien
Mehr zu Contour Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
