Updated (1st comment w/code) - Tile Layout and Figure Properties: export as 'landscape'.

Hello,
  1. I am trying to increase the export size of the plots with Tile Layout which makes them a matlab graphic.
  2. I went into its figure and change its properties to Landscape, paper size A4 and saved the *.mlx file as a word document then download the word document. When I open the word document, the 2 plots are so Small as shown below. The plots are just a fraction of the page height and width. I've tried pdf and having the same issue. What do you recommend? Using the Figure's global settings with 'width and length'?
  3. UPDATE: Is there anyway I can command the legend to be outside the x/y axis? Upon further researched, the legend syntax for 'southwestoutside' at orgin '0,0' will not work because it resizes and pushes the plot to the right. So instead I am using 'southoutside' in font size 7. Is the a way to call up NumRows = 1 instead of NumColumns = 1 in the legend. I am told that it is not a valid syntax.
Thank you in advance for your time and assistance.
Code:
% 5
v = tiledlayout(2,1, 'Padding','loose', 'TileSpacing','loose');
% 5a
nexttile
plot(data1.Simulation_Time, data1.Pitch_Angle, data1.Simulation_Time, data1.Roll_Angle, 'b--');
hold on
grid On;
xlim([0.0000 1500.0000]);
ylim([-35.0 30.0]);
xlabel("Simulation Time (sec)");
ylabel("DEGREES");
legend("Pitch Angle (rad)", "Roll Angle (rad)",'Location', 'southwest');
title("PR I0148A 5a: Pitch and Roll");
% 5b
nexttile
plot(data1.Simulation_Time, data1.Drift_Angle');
hold off
grid On;
xlim([0.0000 1500.0000]);
ylim([-50.0 50.0]);
xlabel("Simulation Time (sec)");
ylabel("DEGREES");
legend("Drift Angle (Port)");
title("PR I0148A 5b: Drift Angle");
Word Document:

3 Comments

Hello,
I have found solutions but am asking for suggestions.
  1. Solution: I am using Tile Layout.
  2. Solution: I have globally set the 'figure' and change its properties.
  3. Solution: Legend - I am using 'southoutside' in font size 7.
  4. 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]});
How are you exporting the figure to pdf (e.g., exportgraphics, print, File>Export menu in the figure, etc.)?
Hello Voss,
With Live Editor.
  • Go to the 'View' tab and 'Hide' the code first
  • Go back to Live Editor
  • Go to the 'Save' tab and select 'Export to PDF'
  • Give it a filename or if you have updated the code, select the same filename.pdf
  • Wait for the prompt window to open
  • You can either print/download or go to the 'Home' tab and download the selected file, filename.pdf.

Sign in to comment.

Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Products

Release

R2022b

Asked:

on 28 Oct 2022

Edited:

on 30 Nov 2022

Community Treasure Hunt

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

Start Hunting!