# plot

Plotting x-y data (2D plot)

### plot(y)

• y should be a vector or matrix, i.e., array having 2 dimensions.
• If y is a vector of size [1, k] or [k, 1], a line of k data points is plotted.
• If size(y) is equal to [np, nl] with np > 1, then nl separate lines of np data points are plotted.
• It uses solid line with the default line colors and no marker.
• It gives the same result as plot(1:np, y), where np is the number of rows of y.

### plot(y, spec)

• The line specification string, spec, should be a character vector specifying values of line attributes.
• It is a concatenation of attribute values, e.g., '-r' means a solid line of red color. An attribute value in a specification string can be over-written by a latter value in the same string. For example, '-.-' gives a solid line since '-.' (dash-dotted line) is overwritten by '-' (solid line). Similarly, 'blackred' gives a red line, instead of a black one.
• spec applies to all plot lines generated for y, and hence all plot lines have the same line and marker styles specified by spec.
• It gives the same result as plot(1:np, y, spec) where np is the number of rows of y.

### plot(y, spec, name1, value1, ..., nameN, valueN)

• name1, ..., nameN are attribute names, and value1, ..., valueN are their corresponding values.
• Attribute values specified by the specification string, spec, can be overwritten by value1, ..., valueN.
• It gives the same result as plot(1:np, y, spec, name1, value1, ..., nameN, valueN) where np is the number of rows of y.

### plot(x, y, spec, name1, value1, ..., nameN, valueN)

• x and y should be vectors or matrices of numeric types.
• If y is of size [m, n], where m>=1 and n>=1, x should be either a matrix of the same size, or a vector of length m or n:
• If x is a matrix, then n lines of m data points will be plotted.
• If x is a vector of length m, then n lines of m data points will be plotted.
• If x is a vector of length n, then m lines of n data points will be plotted.

### plot(x1, y1, spec1, ..., xM, yM, specM, name1, value1, ..., nameN, valueN)

• x1, ..., xM, y1, ..., yM, and spec1, ..., specM are as described above in plot(x, y, spec).
• Any of spec1, ..., specM can be omitted.

Line Specification String

• A line specification string is a concatenation of attribute values.
• E.g., 'r-..' means a red (r) dash-dotted line (-.) with point markers (.).
• The order is not important. E.g., 'r-..' and '.-.r' have the same meaning.
• If multiple values are specified for an attribute, only the last value will assigned.
• If an attribute's value is not specified, the default value will be used. E.g., '--' means a blue dashed line without marker.

Attribute Names and Values

Name Value Description Remarks
'LineStyle' '-' Solid line The default value is '-' if marker style is not specified, and 'none' if otherwise.
'--' Dashed line
'-.' Dash-dotted line
':' Dotted line
'none' No line
'Color' 'r', 'red' Red If a color is not specified, it is assigned to blue, red, orange, black, magenta, green, cyan, or yellow in a cyclic manner. More precisely, the mod(i,n)-th color in the list is used in the i-th line, where n = 8 is the total number of colors in the above list. For example, the 10-th line has red color.

[r,g,b] cannot be used in a specification string.
'g', 'green' Green
'b', 'blue' Blue
'c', 'cyan' Cyan
'm', 'magenta' Magenta
'y', 'yellow' Yellow
'k', 'black' Black
'w', 'white' White
[r, g, b] RGB vector, where 0 ≤ r, g, b ≤ 1
'Marker' 'o' Circle In a specification string, 'none' is reserved for line style and hence cannot be used for marker style.
'+' Plus
'*' Asterisk
'.' Point
's', 'square' Square
'd', 'diamond' Diamond
'x' Cross
'^' Up triangle
'v' Down triangle
'<' Left triangle
'>' Right triangle
'p', 'pentagram' Pentagram
'h', 'hexagram' Hexagram
'none' No marker
'MarkerEdgeColor' Same as "Color" above
'MarkerFaceColor' Same as "Color" above
'MarkerSize' Positive number Marker size (1) Default marker size = 6.0.
'DisplayName' Character vector Name shown in legend (1) Default display name is 'Line'.