Display Markers at Specific Data Points on Line Graph

This example shows how to make a line graph and display markers at particular data points.

Define x and y as 100-element vectors.

x = linspace(0,2*pi,100);
y = sin(x);

Plot x versus y. Display markers every $\pi/2$ data points by superimposing a second graph of just markers over the line graph.

xmarkers = 0:pi/2:2*pi; % place markers at these x-values
ymarkers = sin(xmarkers);

figure
plot(x,y,'b',xmarkers,ymarkers,'b*')

See Also

| |

Was this topic helpful?