Hello,
i am interested in naming points of my plot wiht numbers. So i tried it the following way where i is the number that should describe my node.
for i=1:length(xk)
plot(xk(i),yk(i),sprintf( '#%i'))
i=i+1;
hold on
end
but it didnt work and this error occured:
--->??? Error using ==> plot
--->Error in color/linetype argument
--->Error in ==> Plotten at 51
---> plot(xk(i),yk(i),sprintf( '#%i'))
can anyone help me with that please?
with best regards, John

 채택된 답변

Stephan M. H.
Stephan M. H. 2013년 5월 10일

2 개 추천

Hi John,
where you used sprint, the plot function expects as input LineSpec or 'PropertyName' followed by Propertyvalue.
I guess a direct way would be using the text function
...
plot(xk(i),yk(i))
text(xk(i),yk(i),num2str(i))
best,
Stephan

댓글 수: 3

Thx for your answers!.... trying so, i have the following code:
for i=1:2:length(xk)
plot(xk(i:(i+1)),yk(i:(i+1)),'r-','LineWidth' ,1)
xk(i:(i+1));
yk(i:(i+1));
i=i+2;
hold on
end
for i=1:length(xk)
plot(xk(i),yk(i))
text(xk(i),yk(i),num2str(i))
i=i+1;
hold on;
end
There remains the problem that the node´s numbers are somehow overwritten various times, i cannot explain that because i placed the text command after the line plots as you can see.
best greetz, John
Azzi Abdelmalek
Azzi Abdelmalek 2013년 5월 10일
What i=i+1 is doing in your code?
John
John 2013년 5월 12일
thx i found the mistake...the irritation was due to strange loops^^
it works well now and the numbers arent overwritten anymore.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 5월 10일
편집: Azzi Abdelmalek 2013년 5월 10일

1 개 추천

for i=1:length(xk)
text(xk(i),yk(i),num2str(i))
hold on
end

댓글 수: 1

Without for loop how to provide the numbering to each point.
Means if
x1= 167*rand (50,1);
y1=302* rand (50,1);
plot(x1,y1,'b*');

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Line Plots에 대해 자세히 알아보기

질문:

2013년 5월 10일

댓글:

2018년 12월 8일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by