hgexport
导出图窗
语法
hgexport(fig,filename)
hgexport(fig,'-clipboard')
说明
hgexport(fig,filename)
将图窗 fig
写入到 EPS 文件 filename
。
hgexport(fig,'-clipboard')
将图窗 fig
写入到 Microsoft® Windows® 剪贴板。图窗的导出格式由使用的渲染器决定。Painters 渲染器生成图元文件。OpenGL® 渲染器生成一个图像文件。
备选方法
使用文件 > 导出设置对话框。使用编辑 > 复制图窗以将图窗的内容复制到系统剪贴板。有关详细信息,请参阅保存前自定义图窗和通过“编辑”菜单将图窗复制到剪贴板。
版本历史记录
在 R2006a 之前推出R2022b: 以后的版本将不支持 UI 组件
在以后的版本中,hgexport
函数将不再支持在图窗中保存 UI 组件。
要导出包含 UI 组件的图窗,请调用 exportapp
函数。例如,创建一个包含两个按钮和一个滑块的简单 App。通过调用 exportapp
函数将图的内容导出为 PDF 文件。
% Create figure with three UI components f = uifigure; button1 = uibutton(f,"Position",[150 300 100 50]); button2 = uibutton(f,"Position",[300 300 100 50]); slider1 = uislider(f,"Position",[150 250 250 3]); % Export the contents of the figure exportapp(f,"myapp.pdf")
或者,调用 getframe
函数来捕获图的内容。然后调用 imwrite
函数保存内容。此次,将内容保存为 JPEG 文件。
F = getframe(f);
imwrite(F.cdata,"myapp.jpg");
R2022b: 以后的版本将不支持 PostScript (.ps
) 文件
在以后的版本中,hgexport
函数将不再支持创建全页 PostScript® (.ps
) 文件。要导出向量图文件,请使用以下方法之一:
调用 exportgraphics
函数。指定 .eps
、.pdf
或 .emf
文件扩展名,并将 ContentType
选项设置为 "vector"
。此函数捕获紧密围绕图形裁剪的内容,并且不会创建全页输出。例如,创建一个绘图,并将当前图窗的内容另存为一个包含向量图的 PDF 文件。
plot([0 3 2 4 1]); exportgraphics(gcf,"myplot.pdf","ContentType","vector")
或者,也可以调用 hgexport
函数并指定 .eps
、.emf
或 .svg
文件扩展名。例如,创建一个绘图,并将当前图窗的内容保存为 EPS 文件。
plot([0 3 2 4 1]);
hgexport(gcf,"myplot.eps")
另请参阅
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)