This is not a proper answer, since it does not quite explain why this is happening, but it provides a workaround along with some additional observations of strange behavior.
Application area:
I tried your example and really:
- pre HG2 (R2013a): Same behavior as you described
- HG2 (R2015a): No problem, everything is there.
Workaround:
After several trial and error, I found out that this is a specific painter renderer behavior in versions prior to HG2.
If you change the rendering to any painter other than the default, you will return the image and overlay lines.
set(gcf,'Renderer','zbuffer') %// OR set(gcf,'Renderer','opengl')
Remarks:
Please note that I also tried:
- first display lines (no problem), then image (and reorder with
uistack ) => same black image. - use multiple axes => black frame

And show you how persistent the failure is:
- If you delete all lines, the image will not appear again (= black frame).
- if you delete all graphic objects, then redisplay the image => black frame
- if you are
cla or even clf then redisplay image => black frame
The only way to find the displayed image is to change the rendering as described above.
Print / Save
Initially, I thought that the change in rendering occurred behind the scene when you saved the shape, thereby allowing you to fully display the final output. Unfortunately, learning a little more does not seem so simple.
I tried a different version with print (instead of saveas ), since it allows you to choose the rendering. For each renderer, I chose 2 formats, PDF , which uses the ghostscript engine, and PNG , which uses the Matlab mechanism:
%% print(1,'-dpng','-painters','testimageP.png') print(1,'-dpng','-zbuffer' ,'testimageZ.png') print(1,'-dpng','-opengl' ,'testimageO.png') %% print(1,'-dpdf','-painters','testimageP.pdf') print(1,'-dpdf','-zbuffer' ,'testimageZ.pdf') print(1,'-dpdf','-opengl' ,'testimageO.pdf')
Well, after the results, I'm still not sure what is going on. All these saved numbers show the correct image and the lines at the top ... But:
3x PNG ( Matlab engine) look exactly like that . They do not even show a slight difference in saturation, as you can observe when manually switching the renderer. It made me think that Matlab decided to ignore my rendering specification. He simply decided which one was the most appropriate, and went to print 3 times for the same figure. Therefore, I thought that the painter tool was not used and why the images were displayed.
Well, not so fast. On 3x PDF images ( ghostscript engine) ... I can observe small nuances between 3 images ... so the visualizer was not between them. painter used on one of them and successfully displayed the image.
Thus, it seems that the rendering of the painter is only malfunctioning when applied to the figure (pre-HG2)!