答案 0 :(得分:3)
我只想绘制自己的假轴。我不确定是否有更好的解决方案,但这个有效。
[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);