Inconsistent Figure Behavior if Saved While Figure is Visible vs Saved While Figure is Hidden

1 view (last 30 days)
I have run into an issue where I get a different saved png output if I save a figure while it is set to visible compared to when I save the same figure as it is set to invisible. The visibility component is important, as I intent for this section of code to live in a function that will be used in a parfor which by nature does not allow for figures to be visible.
The sample code uses two sets of axes to plot a PNG background image with a geoscatter layer on top of it. The image layer does not seem to be affected by this issue, but the geoscatter shows a change in the point size, a scaling of the colorbar, and a shift of the plotted data between the two methods. This is demonstrated by the two plots saved by the sample code. The first output 'Visible.png' behaves as expected and is exactly what I see if I manually save the figure, but by simply turning off the visibility and resaving this as 'Hidden.png' I get a noticeably different output.
I do not know if this is a bug, or if there is some lower level setting that I am overlooking somewhere. Ive gone through every local resource I have available to me and have so far come up empty.

Accepted Answer

Walter Roberson
Walter Roberson on 21 May 2021
Some components will not have the correct size calculated until they are rendered by being made visible.
This is a different issue than parfor not being able to display plots. parfor can build plots and set them visible to trigger rendering, but cannot display them to the user.
Also if you need to you could save the parfor generated plots as fig files and then after the parfor do a loop opening the figs and saving to image files.

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!