帮助中心帮助中心
当前图窗的句柄
fig = gcf
示例
fig = gcf 返回当前图窗的句柄。如果图窗不存在,则 gcf 将创建一个图窗并返回其句柄。可以使用图窗句柄查询和修改图窗的属性。有关详细信息,请参阅 Figure 属性。
fig
gcf
全部折叠
设置当前图窗的背景色并删除工具栏。使用 gcf 命令获取当前的图窗句柄。
surf(peaks) fig = gcf; % current figure handle fig.Color = [0 0.5 0.5]; fig.ToolBar = 'none';
当前图窗是图形输出的目标。它是一种图窗窗口,图形命令(如 plot、title 和 surf)可在其中绘制结果。它通常是最后创建或最后用鼠标点击的图窗。
plot
title
surf
通过用户交互方式可以更改当前图窗。当创建图窗并使用此句柄代替 gcf 时,如果需要访问特定的图窗,请在程序代码中存储图窗句柄。
如果要获取当前图窗的句柄而不强制创建不存在的图窗,请查询根对象的 CurrentFigure 属性。
CurrentFigure
fig = get(groot,'CurrentFigure');
figure
clf
gca
get
set
shg
ancestor
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
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:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office