MATLAB Examples

Add Markers to Line Plot

Create a line plot. Display a marker at each data point by including the line-specification input argument when calling the plot function. For example, use '-o' for a solid line with circle markers.

x = linspace(0,10,100);
y = exp(x/10).*sin(4*x);
plot(x,y,'-o')

If you specify a marker symbol and do not specify a line style, then plot displays only the markers with no line connecting them.

plot(x,y,'o')

Alternatively, you can add markers to a line by setting the Marker property as a name-value pair. For example, plot(x,y,'Marker','o') plots a line with circle markers.