文章目录
- Syntax:
- Description
- Examples
- 1.figure
- 2.figure(Name,Value)
- Position 属性: 设置 Figure 的位置和大小
- Name 属性: 设置 Figure 的名称
- NumberTitle 属性: 取消 Figure 名称里默认的数字
- units 属性
- color 属性
- 3.f = figure(___)
- 4.Working with Multiple Figures Simultaneously
- 5.figure(f) 和 figure(n)
Syntax:
- figure
- figure(Name,Value)
- f = figure(___)
- figure(f)
- figure(n)
Description
1.figure
用法:figure creates a new figure window using default property values. The resulting figure is the current figure.
2.figure(Name,Value)
用法:figure(Name,Value) modifies properties of the figure using one or more name-value pair arguments. For example, figure(‘Color’,‘white’) sets the background color to white.
3.f = figure(___)
用法:f = figure(___) returns the Figure object. Use f to query or modify properties of the figure after it is created.
4.figure(f)
用法:figure(f) makes the figure specified by f the current figure and displays it on top of all other figures.
5.figure(n)
用法:figure(n) finds a figure in which the Number property is equal to n, and makes it the current figure. If no figure exists with that property value, MATLAB creates a new figure and sets its Number property to n.
Examples
1.figure
Create a default figure.
如图:
2.figure(Name,Value)
Example: figure(‘Color’,‘white’) creates a figure with a white background.
Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (’ '). You can specify several name and value pair arguments as Name1,Value1,…,NameN,ValueN.
Position 属性: 设置 Figure 的位置和大小
Position 属性的值为一个向量: [left bottom width height]
.
Location and size of the drawable area, specified as a vector of the form [left bottom width height]. This area excludes the figure borders, title bar, menu bar, and tool bars. (此区域不包括图形边框、标题栏、菜单栏和工具栏。)
Element | Description |
---|---|
left | right-aligned Distance from the left edge of the primary display to the inner left edge of the window. This value can be negative on systems that have more than one monitor. If the figure is docked, then this value is relative to the Figure panel within the MATLAB desktop. (主显示器左边缘到窗口内左边缘的距离。在具有多个监视器的系统上,此值可能为负值。如果图形停靠,则此值相对于MATLAB桌面中的图形面板。) |
bottom | Distance from the bottom edge of the primary display to the inner bottom edge of the window. This value can be negative on systems that have more than one monitor. (主显示器底边缘到窗口内底边缘的距离。在具有多个监视器的系统上,此值可能为负值。) |
width | Distance between the right and left inner edges of the figure. (图形的左右内边缘之间的距离。) |
height | Distance between the top and bottom inner edges of the window. (窗户的上下内缘之间的距离。) |
All measurements are in units specified by the Units property.
You cannot specify the figure Position property when the figure is docked.
In MATLAB Online™, the bottom and left elements of the Position vector are ignored.
To place the full window, including the borders, title bar, menu bar, tool bars, use the OuterPosition property.
所有测量的单位都是由units属性指定的。
当图形停靠时,不能指定图形位置属性。
在MATLAB Online™中,位置向量的底部和左侧元素被忽略。
要放置整个窗口,包括边框、标题栏、菜单栏、工具栏,请使用OuterPosition属性。
If the figure is docked, then this value is relative to the Figure panel within the MATLAB desktop. (如果图形停靠,则此值相对于MATLAB桌面中的图形面板。)
Name 属性: 设置 Figure 的名称
Name — Name
‘’ (default) | character vector | string scalar
Name of the figure, specified as a character vector or a string scalar.
Example: figure(‘Name’,‘Results’) sets the name of the figure to ‘Results’.
By default, the name is ‘Figure n’, where n is an integer. When you specify the Name property, the title of the figure becomes ‘Figure n: name’. If you want only the Name value to appear, set IntegerHandle or NumberTitle to ‘off’.
NumberTitle 属性: 取消 Figure 名称里默认的数字
units 属性
Units — Units of measurement
‘pixels’ (default) | ‘normalized’ | ‘inches’ | ‘centimeters’ | ‘points’ | ‘characters’
Units of measurement, specified as one of the values. (测量单位,指定为这些值中的一个值。)
1.‘pixels’ (default): Pixels. Starting in R2015b, distances in pixels are independent of your system resolution on Windows and Macintosh systems:
- On Windows systems, a pixel is 1/96th of an inch.
- On Macintosh systems, a pixel is 1/72nd of an inch.
On Linux® systems, the size of a pixel is determined by your system resolution.
2.‘normalized’: These units are normalized with respect to the parent container. The lower-left corner of the container maps to (0,0) and the upper-right corner maps to (1,1). (这些单元相对于父容器是规范化的。容器的左下角映射到(0,0),右上角映射到(1,1)。)
3.‘inches’: Inches.
4.‘centimeters’: Centimeters.
5.‘points’: Points. One point equals 1/72nd of an inch.
6.‘characters’: These units are based on the default uicontrol font of the graphics root object:
- Character width = width of the letter x.
- Character height = distance between the baselines of two lines of text.
To access the default uicontrol font, use get(groot,‘defaultuicontrolFontName’) or set(groot,‘defaultuicontrolFontName’).
要访问默认的uicontrol字体,使用get(root,‘defaultuicontrolFontName’)或set(root,‘defaultuicontrolFontName’)。
MATLAB measures all units from the lower left corner of the parent object.
This property affects the Position property. If you change the Units property, consider returning its value to the default value after completing your computation to avoid affecting other functions that assume the default value.
The order in which you specify the Units and Position properties has these effects:
If you specify the Units before the Position property, then MATLAB sets Position using the units you specify.
If you specify the Units property after the Position property, MATLAB sets the position using the default Units. Then, MATLAB converts the Position value to the equivalent value in the units you specify.
MATLAB从父对象的左下角开始测量所有单位。
此属性影响Position属性。如果您更改了Units属性,请考虑在完成计算后将其值返回为默认值,以避免影响使用默认值的其他函数。
指定单位和位置属性的顺序有以下效果:
如果您在位置属性之前指定单位,那么MATLAB将使用您指定的单位设置位置。
如果在Position属性之后指定Units属性,MATLAB将使用默认的Units设置位置。然后,MATLAB将Position值转换为您指定的单位的等效值。
color 属性
Background color, specified as an RGB triplet, a hexadecimal color code, a color name, or a short name. If you specify ‘none’, the background color appears black on screen, but if you print the figure, the background prints as though the figure window is transparent.
For a custom color, specify an RGB triplet or a hexadecimal color code.
- An RGB triplet is a three-element row vector whose elements specify
the intensities of the red, green, and blue components of the color.
The intensities must be in the range [0,1], for example, [0.4 0.6
0.7]. - A hexadecimal color code is a character vector or a string scalar
that starts with a hash symbol (#) followed by three or six
hexadecimal digits, which can range from 0 to F. The values are not
case sensitive. Therefore, the color codes “#FF8800”,
“#ff8800”,“#F80”, and “#f80” are equivalent.
Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.
如图:
3.f = figure(___)
f is this figure object.
一个 figure 的所有 property,即所有属性:
使用 f 修改图片的属性来修改图片, 前提是图片存在, 要是把图片删除了则修改属性的语句会报错.
4.Working with Multiple Figures Simultaneously
有多个 Figure 同时存在时, 位于最前面的那个 Figure 就是当前活动的 Figure, 画出的图线会画在 Figure 上. 如图:
5.figure(f) 和 figure(n)
使用此命令可以选中某个 Figure 作为当前活跃窗口. 如图:
input argument f is target figure object.
input argument n is target figure number.
Target figure number, specified as a scalar integer value. When you specify this argument, MATLAB searches for an existing figure in which the Number property is equal to n. If no figure exists with that property value, MATLAB creates a new figure and sets its Number property to n. By default, the Number property value is displayed in the title of the figure.
(目标图形编号,指定为标量整数值。当指定此参数时,MATLAB将搜索Number属性等于n的现有图形。如果不存在具有该属性值的图形,MATLAB将创建一个新图形,并将其Number属性设置为n。默认情况下,Number属性值显示在图的标题中。)