Matlab中保存图像时,图形窗口大小的控制.docx

上传人:11****ws 文档编号:3261980 上传时间:2019-05-27 格式:DOCX 页数:5 大小:64.57KB
下载 相关 举报
Matlab中保存图像时,图形窗口大小的控制.docx_第1页
第1页 / 共5页
Matlab中保存图像时,图形窗口大小的控制.docx_第2页
第2页 / 共5页
Matlab中保存图像时,图形窗口大小的控制.docx_第3页
第3页 / 共5页
Matlab中保存图像时,图形窗口大小的控制.docx_第4页
第4页 / 共5页
Matlab中保存图像时,图形窗口大小的控制.docx_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

1、Matlab 中保存图像时,图形窗口大小的控制 zz首先要了解的是 Matlab 是面向对象的。最高等级的对象是 screen,它定义了figure 可以用的最大 szie。screen 下面是 figure。figue 就是你画图的时候跳出来的那个新的对话窗口。如果 figure 变化,screen 是不会跟着变化的。但 screen 变化的话,figure 就要跟着变化了。figure 下面是 axes。axes 是那个窗口里面你要画的东西。axes 的大小和位置取决于 figure,如果你放大缩小 figure 的大小的话,里面的图线也会跟着变化的。set(gca,position,)因

2、此,set (gca,position,0.1,0.1,0.9,0.9 );的作用是:设置坐标轴距离画板(图形窗口 figure)边距。0.1,0.1,0.9,0.9 分别为 axes 在 figure 中的左边界,下边界,宽度,高度,最小为 0,最大为 1(左边界,下边界为 0,上边界,右边界为 1)见下面的例子:-figureset (gca,position,0.1,0.1,0.9,0.9 );x=1:0.1:10;y=sin(x);plot(x,y)-结果见下图:set(gcf,position,)一般 matlab 绘出来图的框架(图形窗口)大都是正方形或者近似正方形的矩形,能不能画

3、一些扁的矩形呢?使用图形的 position 属性可以做到。如 set(gcf,unit,normalized,position,0.2,0.2,0.64,0.32);的意思是:对 gcf 的 position 进行设置。使其在屏幕上的显示位置是以(0.2,0.2)为原点,长 0.64,宽 0.32。同 gca 一样,仍然是左边界,下边界为 0,上边界,右边界为 1。另外,gcf 的 position 也可以不是 normalized 的。如下面的例子:-x=-2*pi:0.1:2*9i;y=sin(x);figure;set (gcf,Position,500,500,500,500, co

4、lor,w) %大小设置plot(x,y,k-) %节点位移图形输出 xlim(min(s(:,2) max(s(:,2)grid on-其中,500,500,500,500的意思为:原点的位置 x,原点的位置 y,宽,高,其坐标为 points(详见下面),图形窗口启动时为默认模式,使用下面的命令,可以使的打开的 figure 窗口最大化。方法 1:h = figure;set(gcf,outerposition,get(0,screensize);方法 2:h = figure;set(gcf,units,normalized,position,0,0,1,0.9);现在问题还存在:如果仅

5、设置 position 的话,打印的时候还是正方形。可以用下面的方法解决:通常默认情况下,print 命令输出图像为 8*5inches,无视屏幕显示尺寸通过命令行修改的话有三步1 设置 paperposition 为 manualset(gcf,PaperPositionMode, manual) auto | manual 2 设置 paperunitset(gcf,PaperUnits,inches) inches | centimeters | normalized | points 3 设置 paperpositionset(gcf,PaperPosition,left,bottom

6、,width,height)例如set(gcf, PaperPositionMode, manual);set(gcf, PaperUnits, points);set(gcf, PaperPosition, 0 0 640 480);还有一个相关命令是 papersizepaperposition 是 placement,代表图像在 paper(感觉就是屏幕 screen 的意思?)中的所处位置。left 和 bottom 计算好,就可以使图像在 paper 中居中papersize 是纸张大小;position 要比 size 小的PaperPositionfour-element rec

7、t vectorLocation on printed page. A rectangle that determines the location of the figure on the printed page. Specify this rectangle with a vector of the formrect = left, bottom, width, heightwhere left specifies the distance from the left side of the paper to the left side of the rectangle and bott

8、om specifies the distance from the bottom of the page to the bottom of the rectangle. Together these distances define the lower-left corner of the rectangle. width and height define the dimensions of the rectangle. The PaperUnits property specifies the units used to define this rectangle.要使图像比例输出与屏幕

9、显示的一致,可以使用如下命令屏幕显示图像尺寸可以 plot 时用 set(gcf,position,left bottom width height) 调整,或者 print 之前拖动窗口手动调整This example exports a figure at screen size to a 24-bit TIFF file, myfigure.tif.% set(gcf,position,80 100 800 600) % 如果手动拖放,则不需要这一行命令set(gcf, PaperPositionMode, auto) % Use screen sizeprint -dtiff myfi

10、gure用 matlab 画了一张图,投稿时要缩小,缩小后字体就会过小或者发虚。我摸索出比较好的方法是如下的代码:%plot your figure before% figure resizeset(gcf,Position,100 100 260 220);set(gca,Position,.13 .17 .80 .74);figure_FontSize=8;set(get(gca,XLabel),FontSize,figure_FontSize,Vertical,top);set(get(gca,YLabel),FontSize,figure_FontSize,Vertical,middl

11、e);set(findobj(FontSize,10),FontSize,figure_FontSize);set(findobj(get(gca,Children),LineWidth,0.5),LineWidth,2);%解释:set(gcf,Position,100 100 260 220);这句是设置绘图的大小,不需要到 word 里再调整大小。我给的参数,图的大小是 7cmset(gca,Position,.13 .17 .80 .74);这句是设置 xy 轴在图片中占的比例,可能需要自己微调。figure_FontSize=8;set(get(gca,XLabel),FontSize,figure_FontSize,Vertical,top);set(get(gca,YLabel),FontSize,figure_FontSize,Vertical,middle);set(findobj(FontSize,10),FontSize,figure_FontSize);这 4 句是将字体大小改为 8 号字,在小图里很清晰 set(findobj(get(gca,Children),LineWidth,0.5),LineWidth,2);这句是将线宽改为 2

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 重点行业资料库 > 医药卫生

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。