write indexes in a plot
23 ビュー (過去 30 日間)
古いコメントを表示
Luis Isaac
2020 年 2 月 21 日
コメント済み: Giuseppe Inghilterra
2020 年 2 月 21 日
Dear
I have a matrix P with n rows and two columns, each of the column store the x and y position of a particle.
Represent the particle postions is easy (plot(P(:,1),P:,2)), I would like to write the index of each particle just beside each point
How can I do it?
Many thanks!!
0 件のコメント
採用された回答
Giuseppe Inghilterra
2020 年 2 月 21 日
Hi,
look this answer: https://www.mathworks.com/matlabcentral/answers/97277-how-can-i-apply-data-labels-to-each-point-in-a-scatter-plot-in-matlab-7-0-4-r14sp2
Example code taken from above answer:
x = 1:10; y = 1:10; scatter(x,y);
a = [1:10]'; b = num2str(a); c = cellstr(b);
dx = 0.1; dy = 0.1; % displacement so the text does not overlay the data points
text(x+dx, y+dy, c);
This should resolve your problem.
2 件のコメント
Giuseppe Inghilterra
2020 年 2 月 21 日
You can specify fontsize property as follow:
text(x+dx, y+dy, c,'FontSize',k);
with k as scalar value equal to your desired fontsize.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Nonlinear Dynamics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!