I post-process data tables, which result from Design of Experiments with m input parameters, n output parameters and > 100 evaluations/lines. I use scatter plots, which are automatically set up in m*n subplots, such that each row of scatter plots shows the effect of input parameters whereas each column of scatter plots shows the impact on the output parameters. The name of the input and output parameters are currenlty displayed only above the first row and left of the first column of scatter plots in order to save as much space between the scatter plots as possible. Above the first row I use plot title and was able to break the very long title (name + unit)
titlename=strcat(A.Name(col+NumIn),' (',A.Unit(col+NumIn),')');title(titlename,'FontSize',9, 'Interpreter', 'none','Rotation',0);
in several lines according to this code ( https://de.mathworks.com/matlabcentral/answers/224185-how-to-make-long-title-for-a-plot-with-automatic-line-breaks ):
%%%%%%%START BREAKING TITLE LINE%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ha=gca; NoCharPerLine= cellfun('length',titlename)-cellfun('length',A.Unit(col+NumIn))-2; % or whatever you want...
if ismatrix(ha(end).Title.String) && size(ha(end).Title.String,2)>NoCharPerLine II=strfind((ha(end).Title.String(1:NoCharPerLine)),' '); % find last occurence of a space
LastSpaceIndex=II(end); ha(end).Title.String={ha(end).Title.String(1:LastSpaceIndex-1) ; ha(end).Title.String(LastSpaceIndex+1:end)};endif iscell(ha(end).Title.String) while size(ha(end).Title.String{end},2)>NoCharPerLine STR=ha(end).Title.String{end}; II=strfind(STR,' '); % find last occurence of a space LastSpaceIndex=II(end); ha(end).Title.String{end}=STR(1:LastSpaceIndex-1); ha(end).Title.String{end+1}=STR(LastSpaceIndex+1:end); endend %%%%%%%END BREAKING TITLE LINE%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
My question is now how to deal with the automatically concatenated ylables (name+variable+unit) ?
ylabelname=strcat(A.Name(row),' _ ',A.Var(row),' (',A.Unit(row),')');ylabel(ylabelname,'FontSize',9 , 'Interpreter', 'none', 'FontWeight','bold');
Best Answer