MATLAB Answers

Legend position changed after saving a picture

4 views (last 30 days)
micholeodon
micholeodon on 15 May 2019
Commented: micholeodon on 15 Sep 2020
Dear All,
I have generated picture like this with legend nicely placed in the 'best' location.
screen_1.png
However, when I save it using :
saveas(gcf, savePath);
the legend automagically changed its location.
screen_2.png
Why is that and how to overcome that behavior?

  0 Comments

Sign in to comment.

Answers (1)

Vasishta Bhargava
Vasishta Bhargava on 15 Sep 2020
Edited: Vasishta Bhargava on 15 Sep 2020
% if true
% code
%end
saveas(gcf, savePath,'Renderer','pdf');
Use the saveas with renderer argument and file extension option. This ensures the saved and displayed figures properties are not modified

  1 Comment

micholeodon
micholeodon on 15 Sep 2020
Error using saveas
Too many input arguments.
However I found export_fig (https://www.mathworks.com/matlabcentral/fileexchange/23629-export_fig) as a workaround.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by