why am I Unable to overplot a line on a surface plot?
显示 更早的评论
Why am I unable to correctly overplot a "line" on a "surface" plot?
It becomes cracked as shown in the image below. If one observes clearly, I have tried inserting two white lines with heavy linewidth:
one near y=1 and other at y=5, but it is hardly visible.
the code is as below: (DATA ATTACHED)
surface(t,fby,abs(cfsby)); shading flat;
set(gca,'YScale','log')
xlim([17+25./60 17+28./60]); ylim([0.02,1]);
colormap('jet');
caxis([0 0.05]);
set(gca,...
'YTick', [0.01 0.1 0.2 0.5 1 2 3 4 5], 'YTickLabel',[0.01 0.1 0.2 0.5 1 2 3 4 5]);
% Customize appearance
set(gca, 'XMinorTick', 'on', 'YMinorTick', 'on', 'FontSize', 18, 'fontweight', 'b');
set(gca, 'LineWidth', 2.25, 'TickLength', [0.010 0.010]);
% fo = (q .* B) / (2 * pi_value * m);
q = 1.602e-19; % Charge in Coulombs
mo = 2.657*1e-26;
mhe = 6.64*1e-27;
fo = (q .* by_sc * 1e-9) / (2*pi*mo);
fhe = (q .* by_sc * 1e-9) / (2*pi*mhe);
hold on;
% figure;
plot(t,fhe,'--w','LineWidth',5)
hold on;
plot(t,fo,'--w','LineWidth',2)
Any help is appreciated.
Thanks!
采纳的回答
更多回答(1 个)
Plotting on the surface itself is straightforward. It simply requires using the scatteredInterpolant function to create and plot an appropriate ‘z’ value, and using plot3 to plot the lines.
Try this —
mats = dir('*.mat');
for k = 1:numel(mats)
load(mats(k).name)
% whos('-file', mats(k).name)
end
t = t1;
cfsby = cfsby1;
by_sc = bysc1;
% fby
% size(cfsby)
[FBY,T] = ndgrid(fby, t);
surface(t,fby,abs(cfsby)); shading flat;
set(gca,'YScale','log')
xlim([17+25./60 17+28./60]); ylim([0.02,1]);
colormap('jet');
caxis([0 0.05]);
set(gca,...
'YTick', [0.01 0.1 0.2 0.5 1 2 3 4 5], 'YTickLabel',[0.01 0.1 0.2 0.5 1 2 3 4 5]);
% Customize appearance
set(gca, 'XMinorTick', 'on', 'YMinorTick', 'on', 'FontSize', 18, 'fontweight', 'b');
set(gca, 'LineWidth', 2.25, 'TickLength', [0.010 0.010]);
% fo = (q .* B) / (2 * pi_value * m);
q = 1.602e-19; % Charge in Coulombs
mo = 2.657*1e-26;
mhe = 6.64*1e-27;
fo = (q .* by_sc * 1e-9) / (2*pi*mo);
fhe = (q .* by_sc * 1e-9) / (2*pi*mhe);
F = scatteredInterpolant(T(:),FBY(:),abs(cfsby(:))); % Create ‘scatteredInterpolant’ Interpolation Function
zfo = F(double(t),double(fo)); % Return ‘z’ Value
zfhe = F(double(t),double(fhe)); % Return ‘z’ Value
hold on;
% figure;
% plot(t,fhe,'--w','LineWidth',5)
plot3(t,fhe,zfhe,'--w','LineWidth',5)
hold on;
% plot(t,fo,'--w','LineWidth',2)
plot3(t,fo,zfo,'--w','LineWidth',2)
EDIT — (25 Nov 2024 at 02:58)
Showing the surface in 3D illustrates the effect —
figure
surface(t,fby,abs(cfsby)); shading flat;
set(gca,'YScale','log')
% xlim([17+25./60 17+28./60]); ylim([0.02,1]);
colormap('jet');
caxis([0 0.05]);
set(gca,...
'YTick', [0.01 0.1 0.2 0.5 1 2 3 4 5], 'YTickLabel',[0.01 0.1 0.2 0.5 1 2 3 4 5]);
% Customize appearance
set(gca, 'XMinorTick', 'on', 'YMinorTick', 'on', 'FontSize', 18, 'fontweight', 'b');
set(gca, 'LineWidth', 2.25, 'TickLength', [0.010 0.010]);
hold on
% plot(t,fhe,'--w','LineWidth',5)
plot3(t,fhe,zfhe,'--w','LineWidth',5)
% plot(t,fo,'--w','LineWidth',2)
plot3(t,fo,zfo,'--w','LineWidth',2)
view(135,30)
.
类别
在 帮助中心 和 File Exchange 中查找有关 Graphics Object Properties 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



