필터 지우기
필터 지우기

Labeling coordinates of points on a graph?

조회 수: 5 (최근 30일)
Mark
Mark 2012년 7월 24일
댓글: Walter Roberson 2016년 10월 6일
Is it possible to label plotted points, which I have in a table/matrix, on a graph?
e.g. I have a table with 2 columns (for x and y values) and say 10 rows, and plotted thiem using the plot function, could I present the coordinates right next to the point?

채택된 답변

Walter Roberson
Walter Roberson 2012년 7월 24일
for K = 1 : size(XY,1)
thisX = XY(K,1);
thisY = XY(K,2);
labelstr = sprintf('%.2f@%.2f', thisX, thisY);
text(thisX, thisY, labelstr);
end
  댓글 수: 4
Ibrahim Steel
Ibrahim Steel 2016년 10월 5일
for this specific example, XY should be a matrix. it can be created using the command matrix = [vectora,vectorb] if both of your vectors are column vectors (when printed, they list down). if not, you can turn them into column vecors by using ' to transpose them in the command, eg matrix = [vectora',vectorb']
Walter Roberson
Walter Roberson 2016년 10월 6일
Note: R2016b introduced a new function named erase() so you could end up with conflicts in your code if you name your function or script "erase"

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by