Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

mlreportgen.report.Figure class

Package: mlreportgen.report
Superclasses:

Figure reporter

Description

Create a figure reporter with a title, figure, and caption.

Construction

fig = Figure() creates a reporter that makes a snapshot of the figure currently open in MATLAB® and adds it to a report. Use the figure properties to add a caption or change the figure size. The snapshot image is stored in the temporary folder of the report. When the report is closed, the snapshot image is copied into the report and then, the image is deleted from the temporary folder. To prevent the snapshot image files from being deleted, use the Debug property of the report. See mlreportgen.report.Report.

fig = Figure(source) creates a reporter that adds the figure specified by source.

fig = Figure(Name,Value) sets properties using name-value pairs. You can specify multiple name-value pair arguments in any order. Enclose each property name in single or double quotes.

Input Arguments

expand all

See Source property.

Properties

expand all

Figure image, specified as an mlreportgen.report.FormalImage reporter class. The reporter uses gcf to obtain the current MATLAB figure. It uses the formal image reporter to insert the figure into a report. The figure reporter initializes the Snapshot property. Do not reset this property. Use the properties of the FormalImage object to specify the size of the snapshot or its caption.

Figure source, specified as a string or character array indicating the path to a valid figure file, or a valid graphics handle.

Snapshot image format, specified as a string or character array. Supported formats are:

  • auto — Image file format specified in the HG images option in the Report Generator panel of the MATLAB Preferences dialog box

  • .bmp — Bitmap image

  • .gif — Graphics Interchange format

  • .jpg — JPEG image

  • .png — PNG image

  • .emf — Enhanced metafile, supported only in DOCX output on Windows® platforms

  • .svg — Scalable Vector Graphics

  • .tif — Tag Image File format, not supported in HTML output

  • .pdf — PDF image

Source of template for this reporter, specified as one of these values:

  • String or character array specifying the path of the file containing the template for this reporter

  • Reporter or report whose template is used as the template for this reporter or whose template library contains the template for this reporter

  • DOM document or document part whose template is used as the template for this reporter or whose template library contains the template for this reporter

The specified template must be of the same type as the report to which this reporter is appended. For example, for a Word report, TemplateSrc must be a Word reporter template. If the TemplateSrc property is empty, this reporter uses the default reporter template for the output type of the report.

Name of template for this reporter, specified as a string or character array. The template for this reporter is in the template library of the template source (TemplateSrc) for this reporter.

Hyperlink target for this reporter, specified as a string, character array that specifies the link target ID, or an mlreportgen.dom.LinkTarget object. A string or character array value is converted to a LinkTarget object. The link target object immediately precedes the content of this reporter in the output report.

Example: firstchapter.LinkTarget = 'ch1_link';

Methods

createTemplate Create figure template
customizeReporter Create custom figure reporter class
getClassFolder Figure class definition file location
getSnapshotImageGet snapshot image path

Inherited Methods

getImpl Get implementation of reporter

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects (MATLAB).

Examples

Add a Surface Plot Figure to a Report

Add a figure of a surface plot to a report and set its caption and height.

import mlreportgen.report.*
surf(peaks);
report = Report('peaks');
chapter = Chapter();
chapter.Title = 'Figure Example';
add(report, chapter);

fig = Figure();
fig.Snapshot.Caption = '3-D shaded surface plot';
fig.Snapshot.Height = '5in';

add(report, fig);
delete(gcf);
rptview(report);

Add Two Figures to a Report Page

Add two figures to a report. To place them next to each other on the page, use a DOM Table object.

import mlreportgen.report.*
import mlreportgen.dom.*
report = Report('peaks');

surf(peaks(20));
figure = Figure();
peaks20 = Image(getSnapshotImage(figure,report));
peaks20.Width = '3in';
peaks20.Height = [];

surf(peaks(40));
figure = Figure();
peaks40 = Image(getSnapshotImage(figure,report));
peaks40.Width = '3in';
peaks40.Height = [];
delete(gcf);

t = Table({peaks20,peaks40;'peaks(20)','peaks(40)'});
add(report, t);
close(report);
rptview(report);

Introduced in R2017b

Was this topic helpful?