MATLAB sgtitle overlapping with the title of the subplots

71 次查看(过去 30 天)
When I use the subplots with group title (sgtitle), the title of subplots on top are overlapping with the group title. Does anyone have any suggestions to fix this issue? Any help is much appreciated. Sorry the code is quite messy as it is doing few heavy things!
clear; close all; clc;
load matlab.mat
fig = figure('Position', get(0, 'Screensize'));
% Super title for the movies
sgt = sgtitle(strcat('Stresses',' | Amplification Factor:',{' '},num2str(AmplificationFactor)));
for isig = isig_itr % Stress Component to Plot
for sloc = sloc_itr % Shell Thickness Location to Plot
if (showallstresses_index(1) == 1)
% Subplot axes
ax(sp_cnt) = subplot(row_subplot, col_subplot, sp_cnt);
else
ax(1) = subplot(1, 1, 1);
end
MinStress = +inf;
MaxStress = -inf;
hold on
for iPD=1:2
if (IncludeUndeform ==1 || iPD==2)
if (IncludeUndeform ==1 && iPD==2)
alpha(0.35); % Plot the undeformed shape transparent
end
% COLOR USED TO PAINT THE FACE OF THE ELEMENT.
if (iPD == 1)
ColorFace = 'w';
else
ColorFace = 'g';
end
for iel = 1:nel
for iloc = 1:nnod
x(iloc,1) = coord(lotogo(iel,iloc),1);
y(iloc,1) = coord(lotogo(iel,iloc),2);
z(iloc,1) = coord(lotogo(iel,iloc),3);
end
for iloc = 1:nnod
inod = lotogo(iel,iloc);
for idir = 1:nDOFPN
disp(iloc,idir) = 0;
ieqnm = jj(inod,idir);
if (ieqnm ~= 0)
disp(iloc,idir) = disp(iloc,idir) + d(ieqnm);
end
end
end
AmpFactor = (iPD-1)*AmplificationFactor;
for iface=1:1
faceNode = faceN(iface,:);
fill3(x(faceNode,1)+AmpFactor*disp(faceNode,1),z(faceNode,1)+AmpFactor*disp(faceNode,3),y(faceNode,1)+AmpFactor*disp(faceNode,2),ColorFace);
end
end
end
end
hold off
grid on;
colormap('jet')
title_Var = {' TITLE',' TITLE',...
' TITLE',' TITLE',...
' TITLE',' TITLE',...
' TITLE',' TITLE',...
' TITLE',' TITLE',...
' TITLE',' TITLE'};
title(title_Var((isig-1)*3+sloc));
campos(camposxyz) % camera position
camup(camup_vector); % Camera up vector
% subplot counter
sp_cnt = sp_cnt + 1;
xlabel('X');ylabel('Z');zlabel('Y');
daspect([1 1 1])
end
end
Link = linkprop(ax, ...
{'CameraUpVector', 'CameraPosition', 'CameraTarget'});
setappdata(gcf, 'StoreTheLink', Link);
c = colorbar;
set(c, 'Position', [0.95 .11 .01 .8150])
c.Label.String = 'Stress Range';
c.Label.FontSize = 12;
axis tight
  2 个评论
Jan Kappen
Jan Kappen 2019-12-11
Your script does not work:
Unrecognized function or variable 'CreateNormV'.
Error in matlabTest (line 31)
[V1,V2,V3,V1T,V2T,V3T]=CreateNormV(x,y,z,t);

请先登录,再进行评论。

回答(1 个)

Roshni Garnayak
Roshni Garnayak 2019-12-11
You can change the position of the subplots to make the subplot grid title (defined by ‘sgtitle’) visible. To do this, use the following command:
S = subplot('Position',pos);
To know more about it, refer to the following link:
To further customize the plots, you can refer to the following link:https://www.mathworks.com/help/matlab/ref/matlab.graphics.axis.axes-properties.html

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by