Mercurial > repos > public > sbplib
changeset 281:b4ae78a1c2b9
savepng: Added todo and fixed size bug.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 09 Sep 2016 13:14:12 +0200 |
parents | 6a5e94bb5e13 |
children | 18c023aaf3f7 |
files | savepng.m |
diffstat | 1 files changed, 17 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
diff -r 6a5e94bb5e13 -r b4ae78a1c2b9 savepng.m --- a/savepng.m Tue Sep 06 10:36:33 2016 +0200 +++ b/savepng.m Fri Sep 09 13:14:12 2016 +0200 @@ -1,6 +1,21 @@ +% TODO +% Let print size in inches as input parameter +% Smaller boundingbox function savepng(h, filename, dpi) default_arg('dpi', 300) + + handle_units = h.Units; % Save the current units to be able to restore + + % Copy size of figure in centimeters to a place where saveas will honor it + h.Units = 'centimeters'; + h.PaperUnits = 'centimeters'; + h.PaperPosition(3:4) = h.Position(3:4); + + % Save as a bugged eps file. print(h,filename,'-dpng',sprintf('-r%d',dpi)); - % Let print size in inches as input parameter - % Smaller boundingbox + + h.Units = handle_units; % Restore the old units + + + end