在MATLAB中沿各自的轴标记3D曲面图

时间:2017-10-29 14:40:15

标签: matlab matlab-figure

我怀疑在MATLAB中沿各自的轴标记3D曲面图。

for j=1:length(op)
    x = op{j}(:,1);
    z = st:inc:en;
    y = op{j}(:,2:end);
    figure
    surf(x,z,y.','FaceAlpha',1.0) % surface plot
    xlabel('Non-Dimensional Number (k_0a)')
    ylabel('Non-Dimensional Horizontal Force (HF_P)')
    zlabel('Non-Dimensional Porous Parameter (G_S)')
    axis tight
    view(30,40)
    grid on
end

结果是以下3D图,其标签未在各自的轴上对齐。任何有关在各个轴上对标签进行对齐的帮助都非常受欢迎。 非常感谢。

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以设置标签的位置和旋转,如下所示

[x,y] = meshgrid(1:0.5:10,1:20);
z = sin(x) + cos(y);
figure
surf(x,y,z,'FaceAlpha',1.0) % surface plot
xlabel('Non-Dimensional Number (k_0a)','FontSize', 20)
ylabel('Non-Dimensional Horizontal Force (HF_P)','FontSize', 20)
zlabel('Non-Dimensional Porous Parameter (G_S)','FontSize', 20)
axis tight
view(30,40)
grid on


xh = get(gca,'XLabel'); % Handle of the x label
set(xh, 'Units', 'Normalized')
pos = get(xh, 'Position');
set(xh, 'Position',pos.*[1,-0.5,1],'Rotation',-10)
yh = get(gca,'YLabel'); % Handle of the y label
set(yh, 'Units', 'Normalized')
pos = get(yh, 'Position');
set(yh, 'Position',pos.*[1,-0.7,1],'Rotation',30)

结果,

enter image description here

Ref