Fri 25 Nov 2016 02:40:11 PM UTC, comment #2:
Thank you. I quickly tested it, the result is as attached: Now resolution is correct, but canvas size is not the original input size.
In my example code below (and on my Windows machine), the original canvas size of [800,500] is changed to
[800,500]/600*72 = [96,60]
Instead, I'd prefer to keep [800,500].
Suggestion: Only change resolution if not specified as input:
E.g.
if ~any(cellfun(@any,strfind(varargin,'-r'))) % add: if '-r' option is set, do not overwrite
arg_st.ghostscript.resolution = 72;
end % add
(file #39069)
|
Fri 25 Nov 2016 09:08:32 AM UTC, original submission:
Task: Saving a figure to .png as it appears on the screen, using both size and resolution options (e.g. -S800,500, -r600).
Result: While both Options alone work, setting them together overwrites the rsolution with 72.
Example code:
figure(1,'Position',[100,100,800,500]);
plot(randn(100,2))
title('test'); ylabel('y axis'); xlabel('x axis');
pos=get(gcf,'Position');
print('-dpng', 'test.png', '-r600',['-S',num2str(pos(3)),',',num2str(pos(4))]);
The output is of very much lower resolution, probably 72 (cf. below).
The problem may be related to code in the function scripts/plot/util/private/__print_parse_opts__.m, where it says around line 367:
arg_st.ghostscript.resolution = 72;
Simply commenting out this line, the output looks as expected. However, this is probably not the solution for all cases.
|