saveas not saving figure as seen in MATLAB
15 views (last 30 days)
Show older comments
I'm trying to save a large number of plots in a for loop using the saveas and sprintf functions. The figures appear fine in MATLAB. If I manually save them they appear fine as well. However, when I save them with sprintf and saveas the dashed lines turn to solid lines half way across the plot. I've attatched an image below. Here is my method of saving the figure. saveas(p,sprintf('%s_fig.png',site1(i)));
Any ideas on why this happens and how to fix it?

Thanks
1 Comment
A. Sawas
on 8 Apr 2019
Typically, saveas uses the Painters renderer when generating vector graphics files. For some complex figures, saveas uses the OpenGL® renderer instead. If it uses the OpenGL renderer, then the vector graphics file contains an embedded image, which might limit the extent to which you can edit the image in other applications. Also, if saveas uses the OpenGL renderer to generate the file, then transparency is not supported. To ensure that saveas uses the Painters renderer, set the Renderer property for the figure to 'painters'.
If you set the Renderer property for the figure, then saveas uses that renderer. Otherwise, it chooses the appropriate renderer. However, if saveas chooses a renderer that differs from the renderer used for the figure on the display, then some details of the saved figure can differ from the displayed figure. If necessary, you can make the displayed figure and the saved figure use the same renderer by setting the Renderer property for the figure.
Answers (1)
Matt J
on 9 Apr 2019
export_fig is recommended for exporting figures faithfully to their appearance in Matlab.
0 Comments
See Also
Categories
Find more on Printing and Saving in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!