How to move the position of 2D projection of a 3D plot along the Z axis of the same figure?

3 views (last 30 days)
Hello Everyone,
I am trying to plot the 2D projection of a 3D plot beneath the 3D plot . That is, I want the projection of the 3D plot in the xy plane inthe same figure. I am using surf plot for the 3D plot and contourf for the 2D projection. I am having trouble moving the 2D projection along the z axis. In mycode it is at z=0, but I want it to be at the bottom of z axis.
The code is
clc
clear
close all
f=13.56e6; % Fundamental Frequency
T=1/f; % Fundamental Period
omega=2*180*f;
t=0:T*.0001:T;
%************************Triple Fequency Case****************%
k=3; % Number of consecutive Harmonics
Total_Applied_Voltage=300;
V0=(2*Total_Applied_Voltage)/(k+1);
V=nan(1,k);
Omega=nan(1,k);
V_rf=0;
for n=1:1:k
V(n)=V0*(k-n+1)/(k);
Omega(n)=n*omega;
end
discharge_symmetry=1;
theta1=0:5:360;
theta2=0:5:360;
Dc_Self_Bias = nan(length(theta1), length(theta2));
for x=1:1:length(theta1)
for y=1:1:length(theta2)
Vrf=V(1)*cosd(Omega(1)*t+theta1(x))+V(2)*cosd(Omega(2)*t+theta2(y))+V(3)*cosd(Omega(3)*t);
Dc_Self_Bias(x,y)=-(((max(Vrf)+(discharge_symmetry*min(Vrf)))/(1+discharge_symmetry))/Total_Applied_Voltage)*100;
end
end
surf(theta1, theta2, Dc_Self_Bias)
colormap("hsv");
colorbar
xlabel(['\theta_1 ',char(176),''])
ylabel(['\theta_2 ',char(176),''])
zlabel('Dc Self Bias %')
title('Discharge Characteristics')
xlim([min(theta1), max(theta1)])
ylim([min(theta2), max(theta2)])
zlim([min(min(Dc_Self_Bias)), 70])
xticks(min(theta1):30:max(theta1))
yticks(min(theta2):30:max(theta2))
pbaspect([1 1 1])
grid on
grid minor
hold on
contourf(theta1, theta2, Dc_Self_Bias);
colormap("parula");
This is the figure I am getting.
This is the figure I want
Can anyone help me out please? Also whats that colormap that they have used?
Thank you.

Accepted Answer

Star Strider
Star Strider on 10 Apr 2024
Use surfc instead of surf, and then make appropriate changes to 'ZLocation' and 'FaceColor' in the contour part of the plot.
Try this —
% clc
% clear
% close all
f=13.56e6; % Fundamental Frequency
T=1/f; % Fundamental Period
omega=2*180*f;
t=0:T*.0001:T;
%************************Triple Fequency Case****************%
k=3; % Number of consecutive Harmonics
Total_Applied_Voltage=300;
V0=(2*Total_Applied_Voltage)/(k+1);
V=nan(1,k);
Omega=nan(1,k);
V_rf=0;
for n=1:1:k
V(n)=V0*(k-n+1)/(k);
Omega(n)=n*omega;
end
discharge_symmetry=1;
theta1=0:5:360;
theta2=0:5:360;
Dc_Self_Bias = nan(length(theta1), length(theta2));
for x=1:1:length(theta1)
for y=1:1:length(theta2)
Vrf=V(1)*cosd(Omega(1)*t+theta1(x))+V(2)*cosd(Omega(2)*t+theta2(y))+V(3)*cosd(Omega(3)*t);
Dc_Self_Bias(x,y)=-(((max(Vrf)+(discharge_symmetry*min(Vrf)))/(1+discharge_symmetry))/Total_Applied_Voltage)*100;
end
end
figure
hsc = surfc(theta1, theta2, Dc_Self_Bias);
% hsc(1).EdgeColor = [1 1 1]*0.8;
hsc(1).EdgeColor = 'interp'; % Surface Plot
hsc(2).ZLocation = 'zmin'; % Contour Plot
hsc(2).FaceColor = 'flat';
% colormap("hsv");
colormap(turbo)
colorbar
xlabel(['\theta_1 ',char(176),''])
ylabel(['\theta_2 ',char(176),''])
zlabel('Dc Self Bias %')
title('Discharge Characteristics')
xlim([min(theta1), max(theta1)])
ylim([min(theta2), max(theta2)])
zlim([min(min(Dc_Self_Bias)), 70])
xticks(min(theta1):30:max(theta1))
yticks(min(theta2):30:max(theta2))
pbaspect([1 1 1])
grid on
grid minor
The ability to change the level of the contour plot was introduced recently. I believe it is available in R2023b. You can set it anywhere you want, within the limits of the z-axis.
See Contour Properties to make appropriate changes to the contour plot.
.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!