如何保存自定义尺寸的图形 [英] How to save custom-sized figures
问题描述
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?
我最近一直在尝试在MATLAB中创建一个自定义尺寸的图形,并使用saveas函数自动将其保存.特别是,在以我创建文件的大小保存文件时遇到了问题.粗略地说,我的代码如下:
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.
到目前为止,我的代码可以正常工作,因为它可以在屏幕上创建自定义大小的图形,但是似乎可以将图片本身保存为默认大小.奇怪的是,如果我不使用saveas函数并手动保存图形,那么图像将保持其大小.
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.
为了澄清起见,我目前将图形另存为emf,不过如果可行的话,我也愿意使用jpg/png/bmp.
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.
推荐答案
尝试设置以下内容:
set(mygraph, 'PaperPositionMode','auto') %# WYSIWYG
print -dmeta -r0 file.emf
这篇关于如何保存自定义尺寸的图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!