Asked by Luan Gloria
on 14 Feb 2019

Dear MatLab community members,

Let's say I have two vectors, A and B, with ten entries each. B = A*2; Let's say that A=1:1:10;

I want to plot A and B, but instead of ploting circles, crosses etc, I want to plot the index numbers of A and B to show that the content in the position 1 of A is doubled in B. In the picture below I show what I want:

The red dots are the two first entries of vector A, and the blue dots are the two first entries of vector B, however, I cannot correlate these dots among each other (let's say I have a more complicated relationship between A and B, this relation would not be that easily seen). What I want to obtain, is a graph with the vector indexes as in the right side of the graph. Thank you!

Answer by Mark Sherstan
on 14 Feb 2019

Accepted Answer

The following should get you going in the right direction. If you need more help please post your actual data set.

x = [1 2 3]

y = [4 5 6]

plot(x,y,'.','MarkerEdgeColor','w')

xlim([0 5])

ylim([0 10])

for ii = 1:length(x)

t = text(x(ii),y(ii),num2str(ii));

t.Color = [1 0 0];

end

Luan Gloria
on 26 Mar 2019

Thank you Mark! That's exactly what I was looking for.

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 2 Comments

## madhan ravi (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/444937-how-to-plot-index-number-of-a-data-in-the-graph#comment_671213

## Luan Gloria (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/444937-how-to-plot-index-number-of-a-data-in-the-graph#comment_671268

Sign in to comment.