Plot not showing up for last section when publishing

21 views (last 30 days)
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 Comments
Daniel Poiesz
Daniel Poiesz on 18 Apr 2021
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 on 18 Apr 2021
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.

Sign in to comment.

Answers (2)

Sarah
Sarah on 3 Feb 2024
Edited: Sarah on 3 Feb 2024
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 on 26 May 2021
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.

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!