Hello,
I have found solutions but am asking for suggestions.
- Solution: I am using Tile Layout.
- Solution: I have globally set the 'figure' and change its properties.
- Solution: Legend - I am using 'southoutside' in font size 7.
- Question: I still cannot export pdf as 'landscape'. It pdf export below is in portrait mode as a full page.
I have attached the data csv file. Thank you for reviewing and please comment.
% Import the data
question = readtable("/MATLAB Drive/Data/question.csv", opts);
clear opts
question1 = renamevars(question,...
["Sim_Time__Sec___Simulation_Time__Sec_", "VelDrift_PORT__Ft_Sec", "VelHdg_PORT__Ft_Sec"],...
["Simulation_Time", "Velocity_Drift", "Velocity_Heading"]);
% verify
question1;% Create figure - this coding does not work
% figure('PaperOrientation','landscape','PaperType','A4','NumberTitle','off',...
% 'Name','Figure');
figure = gcf;
figure.PaperType = 'A4';
figure.Units = 'inches';
figure.PaperOrientation = 'landscape';
figure.Position = [1 2 7 8];
% figure
% Create multiple captions
% Get the date of the file.
filename = "PH I0148A.pdf";
dirListing = dir(filename);
% Get the current time.
tNow = datetime("now");
% Create a 3 captions on 1 line
caption = sprintf('Run Time = %s', dirListing.date, tNow);
sof_var1 = 'SOF 3.1.0.0.0';
sof_var2 = 'SOF 2.1.9.9.9 ';
DC_Group = 'n/a';
caption2 = sprintf('Build Run 1: %s <> ', sof_var1);
caption3 = sprintf('Build Run 2: %s <> ', sof_var2);
caption4 = sprintf('DC Group 1: %s ', DC_Group);
% Add
% convert fps to knots
question1.DriftVelocity = (question1.Velocity_Drift)./(1.6878);
question1.HeadingVelocity = (question1.Velocity_Heading)./(1.6878);
% verify new variables data
question1;
% Tiled Layout
w = tiledlayout(2, 1,'Padding','loose', 'TileSpacing','loose', 'Units','inches');
nexttile
plot(question1.Simulation_Time, question1.DriftVelocity, 'LineWidth', 1);
hold on
ax = gca; % Get handle to current axes.
ax.GridAlpha = 0.5;
ax.XAxis.TickValues = 0:250:1500;
ax.XMinorTick = 0.9;
ax.XMinorTick='on';
ax.YMinorTick = 0.9;
ax.YMinorTick='on';
ax.XMinorGrid = 'on';
ax.YMinorGrid = 'on';
grid On;
ylim([-15.0 15.0]);
xlabel("Simulation Time (sec)", 'FontSize', 9, 'FontWeight', 'bold');
ylabel("KNOTS", 'FontSize', 9, 'FontWeight', 'bold');
legend("Drift Velocity", 'Location', 'southoutside', 'FontSize', 9);
title("Drift Velocity");
subtitle({caption [caption2, caption3, caption4]});
nexttile
plot(question1.Simulation_Time, question1.HeadingVelocity, 'LineWidth', 1);
hold off
ax = gca; % Get handle to current axes.
ax.GridAlpha = 0.5; % Make grid lines less transparent.
ax.XAxis.TickValues = 0:250:1500;
ax.XMinorTick = 0.9;
ax.XMinorTick='on';
ax.YMinorTick = 0.9;
ax.YMinorTick='on';
ax.XMinorGrid = 'on';
ax.YMinorGrid = 'on';
grid On;
ylim([10.0 65.0]);
xlabel("Simulation Time (sec)", 'FontSize', 9, 'FontWeight', 'bold');
ylabel("KNOTS", 'FontSize', 9, 'FontWeight', 'bold');
legend("Heading Velocity", 'Location', 'southoutside', 'FontSize', 9);
title("Heading Velocity");
subtitle({caption [caption2, caption3, caption4]});