Plot not showing up for last section when publishing

38 次查看(过去 30 天)
I have two sections of code (each section starts with %%), they both have plots in them. When I go to publish, the first section shows the plot immediately after the section/block of code it corresponds to, but the second section doesn't produce the plot. It has something to do with the last section. I repeated the second block of code, so there were a total of 3 sections and the first two sections had plots after them but the last did not. When I run the script both/all plots are produced with no errors. In other words both code blocks are producing the right plots. It's just when I publish for some reason the last section doesn't produce a plot. I don't want to use snapnow because that puts the plots at the very end of the script and I want them to show up after their corresponding code.
Note: there is a section with a function at the very end – could this be affecting it?
  2 个评论
Daniel Poiesz
Daniel Poiesz 2021-4-18
I am having the exact same problem. I moved my code blocks around and it is always the last one that does not display its plots. The last line of code in each of my sections are the plots, so I don't think your function can be causing the problem. I also do not want to use snapnow becaus it places the plots at the end of the document and not in the proper section.
Daniel Poiesz
Daniel Poiesz 2021-4-18
What is even more frustating is if I add a section at the end and plot a straight line then it works. I thought if the last one doesn't plot, then I will add a dummy plot. But then the section I was previously missing will plot followed by the dummy plot. So I can not even fool it into working.

请先登录,再进行评论。

回答(2 个)

Sarah
Sarah 2024-2-3
编辑:Sarah 2024-2-3
Hello,
I had a similar issue. In my case, the last plot was taking too long to generate, so the publishing finished without it. I put in a pause() command for a few seconds after the last plot, and it was successfully displayed in the published pdf. Hope the fix helps anyone with this problem!

Uday Pradhan
Uday Pradhan 2021-5-26
Hello,
The issue is not reproducible at my end. Could you share a snippet of code that reproduces the issue at your end? Also, please attach the MATLAB version number installed on your machine. Thanks.

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by