Gopalpur
Gopalpur

Reputation: 121

Labeling 3D Surface Plots in MATLAB along respective axes

I have doubts regarding Labeling 3D Surface Plots in MATLAB along respective axes.

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

The result is the following 3D plot having labels not alligned in respective axis. Any help on alligning the labels in respective axes is highly appreciated. Many Thanks.

enter image description here

Upvotes: 0

Views: 6747

Answers (1)

Hazem
Hazem

Reputation: 380

You can set the position and the rotation of the label as follow,

[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)

the results,

enter image description here

Ref

Upvotes: 1

Related Questions