User`s guide

13 Create a Report Program
13-76
Create and Format Images
In this section...
“Create an Image” on page 13-76
“Resize an Image” on page 13-77
“Image Storage” on page 13-77
“Links from an Image” on page 13-77
Create an Image
To create an image to a report, create an mlreportgen.dom.Image object. You can
append it to one of these document element objects:
Document
Group
Paragraph
ListItem
TableEntry
For example, you can create a MATLAB figure, save it as an image, and add the image to
a report.
import mlreportgen.dom.*
d = Document('imageArea','html');
p = Paragraph('Plot 1');
p.Bold = true;
append(d,p);
x = 0:pi/100:2*pi;
y = sin(x);
plot(x,y);
saveas(gcf,'myPlot_img.png');
plot1 = Image('myPlot_img.png');
append(d,plot1);