line(x,y)line(x,y,z)line('PropertyName',PropertyValue...)line(...)
line is the low-level graphics function for creating line objects. Line objects are children of axes objects. They are the fundamental graphics objects used to generate plots, contours and edges of surfaces. The line function allows you to specify property name/property value pairs as input arguments. These properties, which control various aspects of the line object, are described under "Object Properties". You can also set and query property values after creating the object using the set and get functions.
Unlike high-level functions such as plot, line does not clear the axes, set viewing parameters, or perform any actions other than generating a line object in the current axes. line is a low-level function that, ordinarily, is not used directly. Use plot and plot3 instead.
line(x,y) adds the line in vectors x and y to the current axes. If x and y are matrices of the same size, line draws one line per column.
line(x,y,z) creates lines in three-dimensional coordinates.
The x, y pair (x, y, z triple for three-dimensional) can be followed by property name/property value pairs to specify additional line properties. You can omit the x, y, pair (x, y, z triple) entirely and specify all properties using property name/property value pairs. For example, the following statements are equivalent:
line('XData',x,'YData',y,'ZData',z)line(x,y,z)
line('PropertyName',PropertyValue...) specifies property name/property value pairs as input arguments.
h = line(...) returns a column vector of handles corresponding to each line object the function creates.Object Properties
This section lists property names along with the type of values each accepts.
ButtonDownFcneval function to execute the specified function. Initially the empty matrix.ChildrenClippingon (Default.) Any portion of the line outside the axes rectangle is not displayed.off Line data is not clipped.ColorColorSpec reference page for more information on specifying color.EraseModenormal (Default.) Redraws the affected region of the display, performing the three-dimensional analysis necessary to ensure that all objects are rendered correctly. This mode produces the most accurate picture, but is the slowest. The other modes are faster, but do not perform a complete redraw and are therefore less accurate.none The line is not erased when it is moved or destroyed.xor The line is drawn and erased by performing an exclusive OR (XOR) with the color of the screen beneath it. When the line is erased, it does not damage the objects beneath it. Lines are dependent on the color of the screen beneath them, however, and are correctly colored only when over the figure background color.background The line is erased by drawing it in the figure's background color. This damages objects that are behind the erased line, but lines are always properly colored.Interruptibleyes The callback specified by ButtonDownFcn is interruptible by other callbacks.no (Default.) The ButtonDownFcn callback is not interruptible.LineStyle-), dashed (- -), dotted (:), dashdot (-.).o), plus (+), point (.), star (*), x-mark (x).LineWidthMarkerSizeParentType'line' for a line object.UserDataget command.Visibleon (Default.) Line is visible on the screen.off Line is not visible on the screen.XDataYData and ZData) must have the same number of rows. line replicates a single column to match the number of columns in other data properties (see "Examples").YDataXData and ZData) must have the same number of rows. line replicates a single column to match the number of columns in other data properties (see "Examples").ZDataXData and YData) must have the same number of rows. line replicates a single column to match the number of columns in other data properties (see "Examples").ZData to produce two lines, each having four points.
line(rand(4,2),rand(4,2),rand(4,1))
If all the data has the same number of columns and one row each, MATLAB transposes the matrices to produce data for plotting. For example,
line(rand(1,4),rand(1,4),rand(1,4))
is changed to
line(rand(4,1),rand(4,1),rand(4,1))
This also applies to the case when just one or two matrices have one column. For example, the statement
line(rand(2,4),rand(2,4),rand(1,4))
is equivalent to,
line(rand(4,2),rand(4,2),rand(4,1))
patch,plot,plot3,text
(c) Copyright 1994 by The MathWorks, Inc.