一、用法解析

1.1. 分辨率-rnumber

1.2.  输出图片的“格式”formats

二、用法示例

2.1. 设置输出图片的“图像纵横比”

2.2. Batch Processing(图片保存“批处理”)filename

1.2. 输出图片的“格式”formats

一、用法解析

print(figure_handle,'formats','-rnumber','filename')

%将图形保存为formats格式,分辨率为600的(默认为72),最好指定的分辨率大一点,否则保存图形的效果较差.

1.1. 分辨率-rnumber

Use -rnumber to specify the resolution of the generated output.

To set the resolution(分辨率) of the output file for a built-in MATLAB format, use the -r switch.

l  For example, -r300 sets the output resolution to 300 dots per inch(每英寸300个点)

The –r switch is also supported for Windows Enhanced Metafiles(增强型图元文件), JPEG, TIFF and PNG files, but is not supported for Ghostscript raster formats(栅格文件).

l  For more information, see Printing and Exporting without a DisplayandResolution Considerations.

—— 来自matlab帮助“print”页中

1.2.  输出图片的“格式”formats

请参考本文末尾

二、用法示例

% Save the figure with the handle h to a PostScript file named Figure1, which can be printed later.

H = figure;   % 指定图片打印figure_handles

% 若没有figure_handle,则默认print当前显示图片

plot(1:4,5:8)

print(h,'-dpng','-r200','Figure1')      % 这三行代码就够用了

2.1. 设置输出图片的“图像纵横比”

When you set the axes Position to [0 0 1 1] so that it fills the entire figure, the aspect ratio is not preserved when you print because MATLAB printing software adjusts the figure size when printing according to the figure's PaperPositionproperty. To preserve the image aspect ratio(图像纵横比) when printing, set the figure's 'PaperPositionMode' to 'auto' from the command line.

set(gcf,'PaperPositionMode','auto')

% Setting the current figure's (gcf) PaperPositionMode to auto enables

% you to resize the figure window and print it at the size you see on the screen.

举例

surf(peaks);shading interp           % 画图,shading使图像美观

axis off                                 % 不显示坐标轴

set(gcf,'PaperPositionMode','auto'); % 设置图像纵横比

print('-dpng','-r200','a');           % 保存图片,名为a

——来自matlab帮助 Printing Images

2.2. Batch Processing(图片保存“批处理”)filename

You can use the function form of print to pass variables containing file names. For example, this for loop uses file names stored in a cell array to create a series of graphs and prints each one with a different file name:

fnames = {'file1', 'file2', 'file3'};

for k=1:length(fnames)

surf(peaks);shading interp

print('-dtiff','-r600',fnames{k}) % fnames is a cell of string arrays so each element is a string

end

————来自matlab帮助“print”页末

注:如果你不能调整输出分辨率和文件格式,可能是"Printing and Exporting without a Display"问题,具体查看帮助“print”页

———分割线————————————————————————————

1.2. 输出图片的“格式”formats

The following table shows the supported output formats for exporting from figures and the switch settings to use. In some cases, a format is available both as a MATLAB output filter and as a Ghostscript output filter. All formats except for EMF are supported on both Windows and UNIX platforms.

Graphics Format

Bitmap or Vector(矢量)

Print Command

Option String

MATLAB or

Ghostscript

BMP monochrome BMP

Bitmap

-dbmpmono

Ghostscript

BMP 24-bit BMP

Bitmap

-dbmp16m

Ghostscript

BMP 8-bit (256-color) BMP (this format uses a fixed colormap)

Bitmap

-dbmp256

Ghostscript

BMP 24-bit

Bitmap

-dbmp

MATLAB

EMF

Vector

-dmeta

MATLAB

EPS black and white

Vector

-deps

MATLAB

EPS color

Vector

-depsc

MATLAB

EPS Level 2 black and white

Vector

-deps2

MATLAB

EPS Level 2 color

Vector

-depsc2

MATLAB

HDF 24-bit

Bitmap

-dhdf

MATLAB

ILL (Adobe Illustrator)

Vector

-dill

MATLAB

JPEG 24-bit

Bitmap

-djpeg

MATLAB

PBM (plain format) 1-bit

Bitmap

-dpbm

Ghostscript

PBM (raw format) 1-bit

Bitmap

-dpbmraw

Ghostscript

PCX 1-bit

Bitmap

-dpcxmono

Ghostscript

PCX 24-bit color PCX file format, three 8-bit planes

Bitmap

-dpcx24b

Ghostscript

PCX 8-bit newer color PCX file format (256-color)

Bitmap

-dpcx256

Ghostscript

PCX Older color PCX file format (EGA/VGA, 16-color)

Bitmap

-dpcx16

Ghostscript

PDF Color PDF file format

Vector

-dpdf

Ghostscript

PGM Portable Graymap (plain format)

Bitmap

-dpgm

Ghostscript

PGM Portable Graymap (raw format)

Bitmap

-dpgmraw

Ghostscript

PNG 24-bit

Bitmap

-dpng

MATLAB

PPM Portable Pixmap (plain format)

Bitmap

-dppm

Ghostscript

PPM Portable Pixmap (raw format)

Bitmap

-dppmraw

Ghostscript

SVG Scalable Vector Graphics (For Simulink Models Only)

Vector

-dsvg

MATLAB

TIFF 24-bit

Bitmap

-dtiff or -dtiffn

MATLAB

TIFF preview for EPS files

Bitmap

-tiff

 

Matlab绘图基础——用print函数批量保存图片到文件(Print figure or save to file)的更多相关文章

  1. Matlab绘图基础——图形修饰处理(入门)

    引入--标题.色条.坐标轴.图例等 例一: set(groot,'defaultAxesLineStyleOrder','remove','defaultAxesColorOrder','remove ...

  2. Matlab绘图基础——用print函数保存图片(Print figure or save to file)

    print(figure_handle,'formats','-rnumber','filename')  %将图形保存为png格式,分辨率为number的(默认为72),最好指定的分辨率大一点,否则 ...

  3. Matlab绘图基础——绘制三维表面

    %绘制三维表面 ------------------------------------- %1.绘制线框图:mesh:每一条曲线称为mesh line %首先利用meshgrid函数产生平面区域内的 ...

  4. Matlab绘图基础——散点生成三角网(TIN)

    %例一:二维三角网TIN模型的生成 X=rand(10,2)*5; dt=DelaunayTri(X(:,1),X(:,2));       %生成三角网 triplot(dt);hold on;   ...

  5. Matlab绘图基础——绘制等高线图

    % 等高线矩阵的获取 C = contourc(peaks(20),3);              % 获取3个等级的等高线矩阵 % 等高线图形的绘制 contour(peaks(20),10);c ...

  6. Matlab绘图基础——一些标准三维曲面

    标准三维曲面 t=0:pi/20:2*pi; [x,y,z]= cylinder(2+sin(t),30);     %[x,y,z]= cylinder(R,n),其中R为圆周半径,n为组成圆周的点 ...

  7. Matlab绘图基础——其他三维图形(绘制填充的五角星)

    其他三维图形 %绘制魔方阵的三维条形图 subplot(2,2,1); bar3(magic(4));   %以三维杆图形式绘制曲线y=2sin(x) subplot(2,2,2); y=2*sin( ...

  8. Matlab绘图基础——利用axes(坐标系图形对象)绘制重叠图像 及 一图多轴(一幅图绘制多个坐标轴)

    描述 axes在当前窗口中创建一个包含默认属性坐标系 axes('PropertyName',propertyvalue,...)创建坐标系时,同时指定它的一些属性,没有指定的使用DefaultAxe ...

  9. Matlab绘图基础——colormap在数字图像处理及三维图形展示上的应用(分层设色)

        色图(color map)是MATLAB系统引入的概念.在MATLAB中,每个图形窗口只能有一个色图.        色图是m×3 的数值矩阵,它的每一行是RGB三元组.色图矩阵可以人为地生成 ...

随机推荐

  1. js部署中如何提高页面加载速度

    1.合并js文件,减少http请求数量. 2.对js文件进行压缩 3.以gzip的形式提供js 4.使js文件可缓存 5.使用CDN

  2. outline的兼容性及使用限制

    outline 和 border的区别: outline不占据文档空间,border占据文档空间. outline无法单独设置上下左右,只要设置outline,必须所有的边都设置:border可以设置 ...

  3. Python 导入与注册

    背景 最近一直学习写一个POC扫描框架,但是不知道如何下手,正巧因为一些需要有朋友在研究POCSuite的实现原理,顺面蹭一些知识点,补一补Python基础的不足,为以后编写POC框架打地基. 导入 ...

  4. 【BZOJ2007】[Noi2010]海拔 对偶图最短路

    [BZOJ2007][Noi2010]海拔 Description YT市是一个规划良好的城市,城市被东西向和南北向的主干道划分为n×n个区域.简单起见,可以将YT市看作 一个正方形,每一个区域也可看 ...

  5. 混合开发中ios兼容问题

    1. z-index无效,设置层级,发现再ios中无效,后来发现是设置了 -webkit-overflow-scrolling:touch 设置这个属性之后.层级设置失效 2.@keyup事件的问题, ...

  6. 170711、Linux下搭建MySQL集群

    一.MySQL集群简介 1.什么是MySQL集群 MySQL集群是一个无共享的(shared-nothing).分布式节点架构的存储方案,其目的是提供容错性和高性能. 数据更新使用读已提交隔离级别(r ...

  7. 软件IT

    软件IT 周期: 攻防:攻击性板块 范畴:科技板块 业务:软件,互联网,人工智能,区块链... 行情主要因素: 主要问题:新领域,成长不确定性高 投资策略: 个股:科大讯飞,中国软件,用友网络,浪潮信 ...

  8. 各大互联网企业Java面试题汇总,看我如何成功拿到百度的offer

    前言 本人Java开发,5年经验,7月初来到帝都,开启面试经历,前后20天左右,主面互联网公司,一二线大公司或者是融资中的创业公司都面试过,拿了一些offer,其中包括奇虎360,最后综合决定还是去百 ...

  9. SpringBoot项目属性配置

    如果使用IDEA创建Springboot项目,默认会在resource目录下创建application.properties文件,在SpringBoot项目中,也可以使用yml类型的配置文件代替pro ...

  10. 解决 Ubuntu 下 Sublime Text 无法输入中文的问题

    解决 Ubuntu 下 Sublime Text 无法输入中文的问题 1. 安装依赖库 sudo apt-get install build-essential sudo apt-get instal ...