matlabfig画图之后fig数据导出

输出 Matlab 图形的一个方法
已有 14778 次阅读
|系统分类:|关键词:matlab,输出图形,figure,exportfig|
经常看到有些人用 Matlab 画图后保存为 EPS 格式或者 PNG 格式的图时字体太小。不太美观。这里把我常用的比较好方法和大家分享一下,也给自己和学生留个印记。附件的 exportfig.m 程序可以很好地把 Matlab 画的图输出为很多格式的文件,并且可以设置字体的大小,颜色等,使用方便灵活。用法很简单, 把这个文件放在 Matlab 的搜索目录中(最简单就是当前的工作目录)。然后:fig=figure(1); &% 定义一个 fig 的图形句柄.... & & % 这里用 plot 等函数画图..exportfig(fig, 'fig2.eps', 'FontMode', 'fixed','FontSize', 10, 'color', 'cmyk' ); &% 把上面画的图(句柄为 fig )保存为 fig2.eps, 字号为 10,彩色。运行以后就可以在当前目录看到一个名为 fig2.eps 的文件了。这个 exportfig() 函数含有很多选项可以灵活设置,详看下面的说明:%EXPORTFIG &Export a figure to Encapsulated Postscript.% & EXPORTFIG(H, FILENAME) writes the figure H to FILENAME. &H is% & a figure handle and FILENAME is a string that specifies the% & name of the output file.%% & EXPORTFIG(...,PARAM1,VAL1,PARAM2,VAL2,...) specifies% & parameters that control various characteristics of the output% & file.%% & Format Paramter:% & & 'Format' &one of the strings 'eps','eps2','jpeg','png','preview'% & & & & &specifies the output format. Defaults to 'eps'.% & & & & &The output format 'preview' does not generate an output% & & & & &file but instead creates a new figure window with a% & & & & &preview of the exported figure. In this case the% & & & & &FILENAME parameter is ignored.%% & & 'Preview' one of the strings 'none', 'tiff'% & & & & &specifies a preview for EPS files. Defaults to 'none'.%% & Size Parameters:% & & 'Width' & a positive scalar% & & & & &specifies the width in the figure's PaperUnits% & & 'Height' &a positive scalar% & & & & &specifies the height in the figure's PaperUnits%% & & Specifying only one dimension sets the other dimension% & & so that the exported aspect ratio is the same as the% & & figure's current aspect ratio. % & & If neither dimension is specified the size defaults to % & & the width and height from the figure's PaperPosition. % & & & & & % & Rendering Parameters:% & & 'Color' & & one of the strings 'bw', 'gray', 'cmyk'% & & & & 'bw' & &specifies that lines and text are exported in% & & & & & & & & black and all other objects in grayscale% & & & & 'gray' &specifies that all objects are exported in grayscale% & & & & 'cmyk' &specifies that all objects are exported in color% & & & & & & & & using the CMYK color space% & & 'Renderer' &one of the strings 'painters', 'zbuffer', 'opengl'% & & & & specifies the renderer to use% & & 'Resolution' & a positive scalar% & & & & specifies the resolution in dots-per-inch.% & & % & & The default color setting is 'bw'.%% & Font Parameters:% & & 'FontMode' & & one of the strings 'scaled', 'fixed'% & & 'FontSize' & & a positive scalar% & & & & &in 'scaled' mode multiplies with the font size of each% & & & & &text object to obtain the exported font size% & & & & &in 'fixed' mode specifies the font size of all text% & & & & &objects in points% & & 'FontEncoding' one of the strings 'latin1', 'adobe'% & & & & &specifies the character encoding of the font%% & & If FontMode is 'scaled' but FontSize is not specified then a% & & scaling factor is computed from the ratio of the size of the% & & exported figure to the size of the actual figure. The minimum% & & font size allowed after scaling is 5 points.% & & If FontMode is 'fixed' but FontSize is not specified then the% & & exported font sizes of all text objects is 7 points.%% & & The default 'FontMode' setting is 'scaled'.%% & Line Width Parameters:% & & 'LineMode' & & one of the strings 'scaled', 'fixed'% & & 'LineWidth' & &a positive scalar% & & & & &the semantics of LineMode and LineWidth are exactly the% & & & & &same as FontMode and FontSize, except that they apply% & & & & &to line widths instead of font sizes. The minumum line% & & & & &width allowed after scaling is 0.5 points.% & & & & &If LineMode is 'fixed' but LineWidth is not specified % & & & & &then the exported line width of all line objects is 1% & & & & &point. %% & Examples:% & & exportfig(gcf,'fig1.eps','height',3);% & & & Exports the current figure to the file named 'fig1.eps' with% & & & a height of 3 inches (assuming the figure's PaperUnits is % & & & inches) and an aspect ratio the same as the figure's aspect% & & & ratio on screen.%% & & exportfig(gcf, 'fig2.eps', 'FontMode', 'fixed',...% & & & & & & & &'FontSize', 10, 'color', 'cmyk' );% & & & Exports the current figure to 'fig2.eps' in color with all% & & & text in 10 point fonts. The size of the exported figure is% & & & the figure's PaperPostion width and height.特别声明,这个程序不是我编的,我只是用了感觉很好,与大家分享。
转载本文请联系原作者获取授权,同时请注明本文来自雷锦志科学网博客。链接地址:
上一篇:下一篇:
当前推荐数:4
推荐到博客首页
评论 ( 个评论)
扫一扫,分享此博文
作者的精选博文
作者的其他最新博文
热门博文导读
Powered by
Copyright & 2007-Matlab导出eps或jpg图片的四种方法
互联网 & 发布时间: 15:44:20 & 作者:佚名 &
Matlab怎么导出eps或jpg图片?方法有很多,之前我们也介绍过,今天我们来给大家补充汇总一下,一共有四种方法,需要的朋友可以进来参考一下
MATLAB是美国MathWorks公司出品的商业数学软件,用于算法开发、数据可视化、数据分析以及数值计算的高级技术计算语言和交互式环境。MATLAB和Mathematica、Maple并称为三大数学软件。它在数学类科技应用软件中在数值计算方面首屈一指。无论是做项目还是写论文,我们都会遇到把Matlab画的图形(默认为matlab自带的图像格式.fig)转换为其他格式并导出的问题。用的最多的图片格式是eps格式(用latex编辑时用)和jpg(用word编辑时用)。下面以matlab 2011b为例介绍多种导出方法。
最简单的方法,但是不灵活。选择Figure文件的&File&菜单下面的&Save As...&。
在弹出的保存窗口中选择具体的保存格式,eps或jpg。另外该方法可以写成命令形式saveas(gcf,'1.eps')或saveas(gcf,'1.jpg'),方便在脚本文件中执行。
该方法只能导出jpg格式的文件,供word中使用。具体方法是点击Figure窗口的&Edit&菜单,选择&Copy Figure&即可把图片导出到windows剪切板中。现在打开一个新的word文件,&Ctrl+v&即可把剪切板中的图片张贴到word中。
采用&Export&对话框进行导出,这也是我比较常用的。因为通常Figure图像边界有空白,上面两种方法需要手动设置figure坐标系的属性才能让图片布满整个窗口(当然也可以用脚本),比较麻烦。而本方法中的&Export&对话框能很好的解决。当然它还有其他更强大的功能。
下面节扫具体的方法。首先Figure窗口&File&菜单,再点击&Export Setup&菜单项。
弹出的Export Setup对话框中进行相应的配置,首先进行导出图片大小的设置,包括长度单位,高和宽,这里一定记得点上&Expand axis to fill figure&以便导出的图像不含空白边框。
再下一个&Rendering&是图片渲染设置。这里其他都可以不用管,主要是dpi需要设置,dpi越高图像越清晰,对于论文工作者而言,很多期刊是要求600dpi以上,这就已经很清楚了。
再下一个&Font&是字体设置。可以按需要设置。
再下一个是对线条的初细进行设置。
最后所有设置好后点击右侧的&aplly to figure&。然后再点export选择要保存的路径及图片格式即可。
最后一种方法是利用print命令,这个也是功能比较强大的函数。可以在Matlab命令窗口输入&help print&命令,打开帮助文件,了解其强大的功能。利用print 导出eps格式图片命令是:print 2.eps -depsc2 -r600,其中-depsc2表示输出eps图像,-r600表示分辨率为600dpi。输出jpg的图片命令是:print 2.jpg -djpeg -r600。
相关推荐:
大家感兴趣的内容
12345678910
最近更新的内容拒绝访问 | www.ggdoc.com | 百度云加速
请打开cookies.
此网站 (www.ggdoc.com) 的管理员禁止了您的访问。原因是您的访问包含了非浏览器特征(44daa7-ua98).
重新安装浏览器,或使用别的浏览器matlab中怎么从fig文件中提取数据集再绘图_百度知道
matlab中怎么从fig文件中提取数据集再绘图
答题抽奖
首次认真答题后
即可获得3次抽奖机会,100%中奖。
綵古駺锝尛蘑菇
綵古駺锝尛蘑菇
采纳数:18
获赞数:45
擅长:暂未定制
如果两条曲线都画在同一个axis里面画完图之后,运行这个,gcf就是当前fig的句柄ah=get(gcf,'children');lineh=get(ah,'children');x1=get(lineh(1),'xdata');y1=get(lineh,(1),'ydata');x2=get(lineh(2),'xdata');y2=get(lineh,(2),'ydata');如果图像是用subplot分成两幅图画在同一个fig里面的画完图之后,运行这个,gcf就是当前fig句柄ah=get(gcf,'children');lineh1=get(ah(1),'children');x1=get(lineh1,'xdata');y1=get(lineh1,'ydata');lineh2=get(ah(2),'children');x2=get(lineh2,'xdata');y2=get(lineh2,'ydata');两中情况的区别是一个是fig里只有1个axis,而axis中有2条曲线一个是fig里有2个axis,而每个axis中只有1条曲线
为你推荐:
其他类似问题
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。网站已改版,请使用新地址访问:
export_fig 一个用于保存matlab生成的图像的工具包,避免一般 时白边的出现。
238万源代码下载- www.pudn.com
&文件名称: export_fig
& & & & &&]
&&所属分类:
&&开发工具: matlab
&&文件大小: 26 KB
&&上传时间:
&&下载次数: 9
&&提 供 者:
&详细说明:一个用于保存matlab生成的图像的工具包,避免一般保存图像时白边的出现。-A tool for storing the generated image matlab package generally kept to avoid the white side of the image appears.
文件列表(点击判断是否您需要的文件,如果是垃圾请在下面评价投诉):
&&export_fig\copyfig.m&&..........\eps2pdf.m&&..........\export_fig.m&&..........\fix_lines.m&&..........\ghostscript.m&&..........\isolate_axes.m&&..........\license.txt&&..........\pdf2eps.m&&..........\pdftops.m&&..........\print2array.m&&..........\print2eps.m&&..........\user_string.m&&..........\readme.txt&&export_fig
&近期下载过的用户:
&相关搜索:
&输入关键字,在本站238万海量源码库中尽情搜索:
&[] - 教你如何熟练处理matlab的画图问题,很实用

我要回帖

更多关于 matlab保存fig 的文章

 

随机推荐