MATLAB Answers

MATLAB sgtitle overlapping with the title of the subplots

153 views (last 30 days)
Preetham Manjunatha
Preetham Manjunatha on 20 Nov 2019
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 Comments

Jan Kappen
Jan Kappen on 11 Dec 2019
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 on 13 Dec 2019
I have modified the code so that there are no dependencies.

Sign in to comment.

Answers (1)

Roshni Garnayak
Roshni Garnayak on 11 Dec 2019
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

  0 Comments

Sign in to comment.

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by