FUNCTION REFERENCE

line

Add a line to the current axes.

Add a line to the current axes.

Syntax

h = line(x, y)

Syntax

h = line(x, y, z)

Syntax

h = line(..., Name, Value)

Syntax

h = line('XData', x, 'YData', y, 'ZData', z, ...)

Draws like plot (matrices give one line per column) but always adds to the current axes, whatever hold says, and never resets the axes. Missing XData or YData default to [0 1]. Name,Value pairs are plot's line properties. When Color is omitted, line uses an inherited DefaultLineColor if set. High-level plot uses the axes ColorOrder for automatic colors.

Example

plot(1:3); h = line([1 3], [3 1], 'Color', 'r'); numel(get(gca, 'Children'))   % 2

Differences from MATLAB: 'Parent' is not supported (select the axes first). Without an inherited default color, the line takes the next colour of the axes ColorOrder.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.