MATLAB Answers

Plots have defect when saved from axes context menu in R2019b

5 views (last 30 days)
DGM on 26 Jul 2021
Edited: DGM on 26 Jul 2021
I ran across this issue when trying to answer a question for someone else:
Whenever I save a plot from the axes context menu (or using print()) in R2019b (linux), the result always has a white horizontal line defect at about 0.625-0.650 of the plot box height. The behavior does not occur in R2015b. The existence and location of the artifact does not seem to depend on x/y data, ylim, or axes/figure geometry. In other words, the defect will still occur in the same spot, regardless of zoom level.
The defect occurs when saving to any raster format (png, jpg, tif), but not if saving to a vector format. I never noticed the problem with plots other than stem(), but it does occur with regular 2D plots using plot(); it's just that stem() makes it very obvious.
For example, consider the very simple case:
x = 0:100;
y = ones(size(x));
stem (x,y,'marker','none');
The defect is at about 0.650 of the plot box height. If I zoom in on the plot and save it ...
... the defect occurs at the exact same position WRT the plot box. If instead, I were to resize the figure ...
... again, the defect is in the same spot WRT the plot box.
This occurs if I save the plot from the axes context menu from either a docked or undocked figure. If the figure is undocked and I use the figure menu, the defect is not present:
If I use print() to save the figure, the defect does occur:
% using print has the same problem in R2019b
% doesn't seem to happen in R2015b
.. but when using getframe() and imwrite(), it does not.
% using getframe and imwrite doesn't have any problems in either version
S = getframe(gcf)
Matlab is using software OpenGL renderer, though I don't know if that is of consequence regarding print().
I didn't find any bug reports, but I know that MW doesn't publish reports for all valid bugs.
Has anyone else noticed this, or can anyone at least replicate this behavior?
I'm not terribly concerned about finding a workaround since I can just save the figure. I'm more curious as to whether this is an extant bug or something that needs attention.

Answers (0)




Community Treasure Hunt

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

Start Hunting!