文档

line

创建原始行

句法

线(x,y)
线(X,,,,y,,,,z)
line
line('xdata',x,'ydata',y)
line('xdata',x,'ydata',y,'zdata',z)
线(___,,,,名称,价值)
线(斧头,___
pl =线(___

Description

例子

线(X,,,,y使用向量中的数据在当前轴上绘制一条线Xy。如果eitherX或者y,或两者都是矩阵,然后line绘制多行。基于颜色和线样式的功能循环颜色Order线型Order轴的性质。不像阴谋功能,line将线路添加到当前轴,而无需删除其他图形对象或重置轴属性。

例子

线(X,,,,y,,,,z将一条线绘制为三维坐标。

linedraws a line from the point(0,0)to(1,1)使用默认属性设置。

例子

line('xdata',X,'ydata',y是低级版本的线(x,y)。The behavior is the same as线(x,y),,,,except that the line has the default line color. Also, you cannot setX或者y矩阵数据。

line('xdata',X,'ydata',y,'zdata',z是低级版本的线(X,,,,y,,,,z)。The behavior is the same as线(X,,,,y,,,,z),,,,except that the line has the default line color. Also, you cannot setX,,,,y, 或者z矩阵数据。

例子

线(___,,,,名称,价值modifies the appearance of the line using one or more name-value argument pairs. For example,'LineWidth',3放s the line width to3点。在所有其他输入参数之后,指定名称值对。

线(斧头,,,,___在指定的轴上创建线路斧头而不是在当前轴(gca)。Specify斧头作为第一个输入参数。

例子

pl= line(___returns all primitive线创建的对象。采用pl修改特定的属性线目的after it is created. For a list, see线Properties

Examples

全部收缩

创造Xy作为向量。然后绘制y相对X

X= linspace(0,10); y = sin(x); line(x,y)

Plot two lines by specifyingXy作为矩阵。采用lineto plot columns ofy与列Xas separate lines.

X= linspace(0,10)'; y = [sin(x) cos(x)]; line(x,y)

通过指定在3-D坐标中绘制一条线X,,,,y, 和zvalues. Change the axes to a 3-D view using查看(3)

t = linspace(0,10*pi,200); x = sin(t); y = cos(t); z = t; line(x,y,z) view(3)

创造Xy作为向量。然后绘制y相对X使用低级版本的line功能。

X= linspace(0,10); y = sin(x); line('xdata',,,,X,,,,'ydata',,,,y)

Draw a red, dashed line between the points (1,2) and (9,12). Set the颜色线型属性作为名称值对。

X= [1 9]; y = [2 12]; line(x,y,'Color',,,,'红色的',,,,'LineStyle',,,,' - '

First, draw a line from the point (3,15) to (2,12) and return the线目的。然后将行更改为绿色的虚线。

笔记:Starting in R2014b, you can use dot notation to set properties. If you are using an earlier release, use thefunction instead.

X= [3 2]; y = [15 12]; pl = line(x,y);

pl。颜色='绿色';pl.linestyle =' - ';

输入参数

全部收缩

Xvalues, specified as a vector or a matrix.

Example:X= linspace(0,10,25)

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|Uint64|categorical|约会时间|期间

yvalues, specified as a vector or a matrix:

  • 如果Xy都是相同长度的向量,然后line绘制一条线。

  • 如果Xyare matrices with the same size, thenline绘制多行。功能图y相对X

  • 如果一个X或者y是向量,另一个是矩阵,然后line绘制多行。The length of the vector must equal one of the matrix dimensions:

    • 如果向量长度等于矩阵行的数量,则line阴谋s each matrix column versus the vector.

    • 如果the vector length equals the number of matrix columns, thenline绘制每个矩阵行与向量的绘制。

    • 如果矩阵是广场,然后line图与向量相比。

Example:y = sin(x)

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|Uint64|categorical|约会时间|期间

zvalues, specified as a vector or a matrix:

  • 如果X,,,,y, 和zare all vectors with the same length, thenline绘制一条线。

  • 如果X,,,,y, 和z都是矩阵的大小相同,然后line使用矩阵列绘制多条线。

  • 如果one or two ofX,,,,y, 和z是矢量,其他是相同大小的矩阵,然后line绘制多行。The length of the vector must equal one of the matrix dimensions.

Example:z= sin(x) + cos(y)

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|Uint64|categorical|约会时间|期间

Target axes, specified as anAxes对象或一个PolarAxes目的。如果您不指定轴,则line当前轴中的功能图。

名称值对参数

指定可选的逗号分隔对名称,价值arguments.Name是参数名称和价值是相应的值。Name必须出现在单引号中(' ')。You can specify several name and value pair arguments in any order asName1,Value1,...,NameN,ValueN

Example:线(X,,,,y,,,,'Color','red','LineWidth',3)creates a red line that is 3 points wide.

这里列出的属性只是子集。有关完整列表,请参阅线Properties

全部收缩

线color, specified as an RGB triplet or one of the color options listed in the table.

For a custom color, specify an RGB triplet. 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];例如,[0.4 0.6 0.7]。Alternatively, you can specify some common colors by name. This table lists the long and short color name options and the equivalent RGB triplet values.

选项 Description Equivalent RGB Triplet
'红色的'或者'r' 红色的 [1 0 0]
'绿色'或者'g' Green [0 1 0]
'blue'或者'b' 蓝色的 [0 0 1]
'yellow'或者'y' 黄色的 [1 1 0]
'magenta'或者'm' 品红 [1 0 1]
'青色'或者'c' Cyan [0 1 1]
'白色的'或者'W' 白色的 [1 1 1]
'black'或者'k' 黑色的 [0 0 0]
'没有任何' 不color 不适用

Example:线(X,,,,y,,,,'Color','blue')

Example:线(x,y,'颜色',[0.5 0.5 1])

线样式,指定为此表中列出的行样式之一。

线样式 Description Resulting Line
' - ' Solid line

' - ' 虚线

':' 虚线

' - 。' 破折号线

'没有任何' 不line 不line

线width, specified as a positive value in points. If the line has markers, then the line width also affects the marker edges.

Example:0.75

标记符号,指定为此表中列出的值之一。默认情况下,对象不显示标记。指定标记符号会在每个数据点或顶点添加标记。

价值 Description
'o' 圆圈
'+' Plus sign
'*' 星号
'。' 观点
'X' Cross
'square'或者' 正方形
'diamond'或者'd' 钻石
'^' 向上的三角形
'v' Downward-pointing triangle
'>' 右点三角形
'<' Left-pointing triangle
'pentagram'或者'P' 五点星(Pentagram)
'hexagram'或者'h' 六点明星(Hexagram)
'没有任何' 没有标记

标记大小,指定为点的正值。

Example:10

Output Arguments

全部收缩

原始线对象。采用pl在创建线路后查询或修改该行的属性。对于列表,请参阅线Properties

Tips

  • 不像阴谋功能,theline功能不调用newplotbefore plotting and does not respect the value of theNextPlotproperty for the figure or axes. It simply adds the line to the current axes without deleting other graphics objects or resetting axes properties. However, some axes properties, such as the axis limits, can update to accommodate the line.

在R2006a之前引入

这个话题有帮助吗?