How to increase the size of figures in Report Generator

조회 수: 6 (최근 30일)
Blue
Blue 2021년 10월 14일
Hello,
I want to have 2 figures per page in my report but I cant figure out how to maximize the size of my figures so that I am left with an 1 inch margin around each page. Best I could manage is below.
Any ideas ?
Thank you,
import mlreportgen.report.*
import mlreportgen.dom.*
rpt = Report('test', 'pdf');
open(rpt)
for i = 1:3
x = [1 2 3 4];
y = [2 4 6 8];
% raw scatter plot
figure();
scatter(x, y);
title('raw data')
xlabel('x axis');
ylabel('y axis');
set(gcf, 'Position', [200 200 600 450])
% Format figure for document
figure = Figure();
img = Image(getSnapshotImage(figure, rpt));
img.Width = '5.2in';
img.Height = [];
halign = mlreportgen.dom.HAlign('center');
img.Style = [img.Style(:)' {halign}];
delete(gcf);
% Add figure to document
add(rpt, img);
% Log data scatter plot with outliers
figure();
scatter(log(x), log(y));
title('log data')
xlabel('x axis');
ylabel('y axis');
set(gcf, 'Position', [200 200 600 450])
% Format figure for document
figure = Figure();
img = Image(getSnapshotImage(figure, rpt));
img.Width = '5.2in';
img.Height = [];
halign = mlreportgen.dom.HAlign('center');
img.Style = [img.Style(:)' {halign}];
delete(gcf);
% Add figure to document (2 figures per page)
add(rpt, img);
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Report Generator Task Examples에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by