필터 지우기
필터 지우기

Publishing a plot with a caption

조회 수: 17 (최근 30일)
Salvatore Pace
Salvatore Pace 2017년 9월 16일
답변: Duncan Lilley 2017년 9월 19일
I am trying to use the publish function to create a pdf of my code and the output. I want to have the graph outputted first and then a caption describing the graph right under it. Right now my code is approximately:
fplot(....)
Disp('...')
However, when I publish the output to a pdf, the caption is outputted first and then the graph. How can I make the graph outputted first and then the caption?

답변 (1개)

Duncan Lilley
Duncan Lilley 2017년 9월 19일
The functionality you have described can be achieved with the "snapnow" function, which forces a snapshot of an image for inclusion in a published document. The image appears in the published document at the end of the cell that contains the "snapnow" command. Take, for example, the following code:
for i = 1:3
figure;
plot(rand(5));
snapnow
disp(['Figure ' num2str(i)]);
end
Another workaround to achieve this is to use "text" or "annotation" to embed some text within the figure itself. Then, this text will always be displayed with the figure. Consider the following code:
fplot(@(x) sin(x));
figLabel = {'Figure 1: A plot of sin(x)'};
dim = [0.1, 0.07, 0, 0];
annotation('textbox', dim, 'String', figLabel, 'FitBoxToText', 'on', 'LineStyle', 'none');
A figure can be edited using the plot tools, which allows for this annotation to be aligned more easily.

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by