# 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 versusY 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:

| Symbol   | Description                       |
| -------- | --------------------------------- |
| **'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:

| Style    | Description                  |
| -------- | ---------------------------- |
| **'-'**  | 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:

| Color   | Description   |
| ------- | ------------- |
| **'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-d3e7b339d39caaf0c246a059e72f666d1dd84391%2Fplot_y.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-f0b61793a404d3aafd6ab69dc2a9b37ed3949794%2Fplot_xy.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-3905dfdef16b8098ca6094dfb270f8f0076d4c7b%2Fplot_multiple.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-10076bafcc05abea2704b6d85a4e60300b230a7c%2Fplot_markers.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-ef3867f0604f69bb7cf2438a4af2ec6d1f813b9f%2Fplot_title.svg?alt=media)

## 🔗 See also

[line](https://nelson-9.gitbook.io/nelson/markdown/en/graphics/line), [plot3](https://nelson-9.gitbook.io/nelson/markdown/en/graphics/plot3), [name=value syntax](https://nelson-9.gitbook.io/nelson/markdown/en/interpreter/name_value_syntax).

## 🕔 History

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