簡體   English   中英

MATLAB中3D表面上的附加軸

[英]Additional axis on 3D surface in MATLAB

假設我使用繪制三維圖形

[X,Y,Z] = peaks(25);
figure
surf(X,Y,Z);

如何將帶有標簽的附加x和y軸添加到z = 0平面,就像這張圖片中顯示的紅色一樣? 我想保持原軸不變。 在此輸入圖像描述

我只想繪制自己的假軸。 我不確定有更好的解決方案,但這個有效。

[X,Y,Z] = peaks(25);
figure
surf(X,Y,Z);

hold on;

%define the plot limits
xlim_arr = [-4 4];
ylim_arr = [-5 5];
zlim_arr = [-10 10];

%fix the limits of the real axes
xlim(xlim_arr);
ylim(ylim_arr);
zlim(zlim_arr);

%add grid and labels through all x-points
for i=xlim_arr(1):xlim_arr(2)
    plot3([i i],[ylim_arr(1) ylim_arr(2)], [0 0], 'Color', [0.7 0.7 0.7], 'LineWidth',0.4);

    text(i, ylim_arr(1)-0.4, 0, num2str(i));
    text(i, ylim_arr(2)+0.4, 0, num2str(i));
end

%add grid and labels through all y-points
for i=ylim_arr(1):ylim_arr(2)
    plot3([xlim_arr(1) xlim_arr(2)], [i i], [0 0], 'Color', [0.7 0.7 0.7], 'LineWidth',0.4);

    text(xlim_arr(1)-0.4, i, 0, num2str(i));
    text(xlim_arr(2)+0.4, i, 0, num2str(i));
end

%add the bold frame to highlight the fake axes
px = [xlim_arr(1) xlim_arr(1) xlim_arr(2) xlim_arr(2) xlim_arr(1)];
py = [ylim_arr(1) ylim_arr(2) ylim_arr(2) ylim_arr(1) ylim_arr(1)];
pz = [0 0 0 0 0];

plot3(px,py,pz, 'k', 'LineWidth', 0.5);

在此輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM