# plot

Linear 2-D plot.

## Syntax

* plot(Y)
* plot(X1, Y1, ...)
* plot(X1, Y1, LineSpec, ...)
* plot(..., propertyName, propertyValue, ...)
* plot(ax, ...)
* go = plot(...)

## Input argument

* X1 - x-coordinates: vector or matrix.
* Y1 - y-coordinates: vector or matrix.
* LineSpec - Line style, marker, and/or color: character vector or scalar string.
* ax - a scalar graphics object value: parent container, specified as a axes.
* propertyName - a scalar string or row vector character. see help of 'line' for property list.
* propertyValue - a value.

## Output argument

* go - a graphics object: line type.

## Description

plot(Y) plots the columns of Y versus their index.

plot(X, Y) plots line defined by X versus Y pair.

go = plot(...) returns a column vector of line graphics objects.

LineSpec is a string used to change the characteristics of the line and is composed of three optional parts in any order:

The SymbolSpec specifies the symbol to be drawn at each data point:

'o': Circle symbol

'x': Times symbol

'+': Plus symbol

'\*': Asterisk symbol

'.': Dot symbol

's': Square symbol

'd': Diamond symbol

'v': Downward-pointing triangle symbol

'^': Upward-pointing triangle symbol

'>': Left-pointing triangle symbol

'<': Right-pointing triangle symbol

The LineStyleSpec specifies the line style to use for each data series:

'-': Solid line style

'--': Dashed line style

'-.': Dot-Dash-Dot-Dash line style

':': Dotted line style

The ColorSpec specifies the line color to use for each data series:

'k': Color Black

'y': Color Yellow

'm': Color Magenta

'c': Color Cyan

'r': Color Red

'b': Color Blue

'g': Color Green

see line for more information about properties

## Examples

Default abscissae using indices:

```matlab
f = figure()
plot(sin(0:0.1:2*pi))
```

![](https://160667757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LdPvJ6mJve3gz5MU4d1%2Fuploads%2Fgit-blob-a994ec9d0349ff62aed0f91164bb2b1a119e858a%2Fplot_y_194D5EC3.svg?alt=media)

Using explicit abscissae:

```matlab
f = figure()
x = [0:0.1:2*pi]';
plot(x, sin(x))
```

![](https://160667757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LdPvJ6mJve3gz5MU4d1%2Fuploads%2Fgit-blob-3faf02eef4f79a6e2066d6c63e854e5c1bf732da%2Fplot_xy_14D7C1E9.svg?alt=media)

Multiple curves with shared abscissae:

```matlab
f = figure()
x = [0:0.1:2*pi]';
plot(x, [cos(x), cos(2*x), cos(3*x)])
```

![](https://160667757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LdPvJ6mJve3gz5MU4d1%2Fuploads%2Fgit-blob-18dbf111d4771a9fd9246a8e2cab7b1e108c03d2%2Fplot_multiple_8629711E.svg?alt=media)

Color and Size of Markers:

```matlab
f = figure();
x = -pi:pi/10:pi;
y = tan(sin(x)) - sin(tan(x));
plot(x ,y, '--rs','LineWidth', 2, 'MarkerEdgeColor','k', 'MarkerFaceColor','g', 'MarkerSize', 11)
```

![](https://160667757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LdPvJ6mJve3gz5MU4d1%2Fuploads%2Fgit-blob-c366e23b422b53de2120d84075a18321ca2b75dd%2Fplot_markers_75AE61C9.svg?alt=media)

Adding Title and Axis Labels:

```matlab
f = figure();
x = linspace(0, 10, 150);
y = sin(5*x);
plot(x,y,'Color',[0,0.7,0.9])
title(_('2-D Line Plot'))
xlabel('x')
ylabel('sin(5x)')
```

![](https://160667757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LdPvJ6mJve3gz5MU4d1%2Fuploads%2Fgit-blob-669a09ca01c6bae69f636ff02fb35ab6dd69b041%2Fplot_title_1B593B7B.svg?alt=media)

## See also

[line](line), [plot3](plot3).

## History

| Version | Description     |
| ------- | --------------- |
| 1.0.0   | initial version |

## Author

Allan CORNET
