Add margin to pdf files using exportgrahics function
Afficher commentaires plus anciens
Hi team
I am using exportgrahics function within my loop to append figures as pdf files and merge them in one pdf file as a final outcome. All good except there are absolutely no margin at all. I want to add atleast half an inch margin on all sides (top bottom left right). I have tried different things but can't add margin to my final pdf file. Can someone please help me? I have pasted part of my codes here. You can just generate dummy plots in loop and please use exportgraphics to merge them in pne file as pdf.
If exportgraphics is not suitable function then please let me know alternative codes. I have also attached my output pdf file. Thank you.
% FIG 1
figure;
plot(Date, Close, 'b-', 'LineWidth', 1, 'DisplayName', company);
grid on;
xlabel('Year');
ylabel(company);
xlim([min(Date), max(Date) + 200])
ylim([min(Close), max(Close) * 1.1])
ytickformat('%,.0f');
hold on
scatter(Px, Py, 50, 'green', 'filled', 'DisplayName', 'Positions');
hold off
lgd = legend;
lgd.NumColumns = 3;
yyaxis right; % Secondary axis
plot(Date_N, Close_N, 'k', 'LineWidth', 0.25, 'DisplayName', 'NIFTY-50');
ylabel('NIFTY-50');
xlim([min(Date_N), max(Date_N) + 200])
ylim([min(Close_N), max(Close_N) * 1.1])
set(lgd, 'Location', 'northwest');
title(company, newline);
ax = gca;
ax.YAxis(2).Exponent = 0;
ax.YAxis(1).Color = 'k';
ax.YAxis(2).Color = 'k';
ytickformat('%,.0f');
set(gcf, 'PaperOrientation', 'landscape', 'Visible', 'off', ...
'Position', [100, 100, 1100, 550]);
exportgraphics(gcf, output_pdf, 'Append', true);
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Printing and Saving dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!