Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Create primitive line

`line(x,y)`

`line(x,y,z)`

`line`

`line('XData',x,'YData',y)`

`line('XData',x,'YData',y,'ZData',z)`

`line(___,Name,Value)`

`line(ax,___)`

`pl = line(___)`

`line(`

plots
a line in the current axes using the data in vectors `x`

,`y`

)`x`

and `y`

.
If either `x`

or `y`

, or both are
matrices, then `line`

draws multiple lines. The
function cycles through colors and line styles based on the `ColorOrder`

and `LineStyleOrder`

properties
of the axes. Unlike the `plot`

function, `line`

adds
the line to the current axes without deleting other graphics objects
or resetting axes properties.

`line`

draws a line from the point `(0,0)`

to `(1,1)`

with
the default property settings.

`line(___,`

modifies
the appearance of the line using one or more name-value argument pairs.
For example, `Name,Value`

)`'LineWidth',3`

sets the line width
to `3`

points. Specify name-value pairs after all
other input arguments.

`line(`

creates
the line in the axes specified by `ax`

,___)`ax`

instead of
in the current axes (`gca`

). Specify `ax`

as
the first input argument.

returns
all primitive `pl`

= line(___)`Line`

objects created. Use `pl`

to
modify properties of a specific `Line`

object after
it is created. For a list, see Primitive
Line Properties.

Unlike the

`plot`

function, the`line`

function does not call`newplot`

before plotting and does not respect the value of the`NextPlot`

property 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.

Was this topic helpful?