MATLAB sgtitle overlapping with the title of the subplots

조회 수: 71 (최근 30일)
Preetham Manjunatha
Preetham Manjunatha 2019년 11월 20일
댓글: Preetham Manjunatha 2019년 12월 13일
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);
Preetham Manjunatha
Preetham Manjunatha 2019년 12월 13일
I have modified the code so that there are no dependencies.

댓글을 달려면 로그인하십시오.

답변 (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