How to save custom-sized figures [duplicate]

北城以北 提交于 2020-01-23 13:02:41

问题


Possible Duplicates:
Printing a MATLAB plot in exact dimensions on paper
How do I save a plotted image and maintain the original image size in MATLAB?

I have recently been trying to create a custom-sized graph in MATLAB and save it automatically using the saveas function. In particular, I am having issues saving the files in the size that I create them. Roughly speaking, my code is as follows:

mygraph = figure('Position',[1,20,1280,1024]);
% creates a figure positioned 1 px from the left of the screen
% 20 px from the bottom of the screen
% that is 1280 px in length and 1024 px in height

% some code to create graph

saveas(mygraph,'mygraphfilename','emf')
% saves figure as mygraphfilename.emf. 

So far, my code works fine in that it can create a custom sized graph on my screen, but it seems to save the pictures themselves in a default size. The weird thing is that if I do not use the saveas function and save the figure manually, then the image retains its size.

For clarification purposes, I'm currently saving the graphs as emf, though I'm also open to using jpg/png/bmp if works fine too.


回答1:


Try setting the following:

set(mygraph, 'PaperPositionMode','auto')     %# WYSIWYG
print -dmeta -r0 file.emf


来源:https://stackoverflow.com/questions/6508233/how-to-save-custom-sized-figures

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!