1 view (last 30 days)

Sindar
on 16 Feb 2020

Assuming you have access to the data (x,y) which generated the plot:

% generate sample x,y

x=1:1000;

% generate 1000 random integers between -5 and 5

y=randi([-5,5],1000)

% plot the data as a black line

plot(x,y,'k')

% find indices where y is 0

idx = (y==0);

% add to the existing plot, with red asterisks where y is zero

hold on

myplot = plot(x(idx),y(idx),'*r')

% with Matlab 2019b, you can programmatically label these points

for ind=idx

datatip(myplot,x(ind),y(ind))

end

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 2 Comments

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/505836-is-there-a-way-to-put-a-marker-on-all-of-the-points-where-y-0-on-a-plot#comment_798174

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/505836-is-there-a-way-to-put-a-marker-on-all-of-the-points-where-y-0-on-a-plot#comment_798174

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/505836-is-there-a-way-to-put-a-marker-on-all-of-the-points-where-y-0-on-a-plot#comment_798182

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/505836-is-there-a-way-to-put-a-marker-on-all-of-the-points-where-y-0-on-a-plot#comment_798182

Sign in to comment.