How can I use index numbers as markers in SCATTER?

2 ビュー (過去 30 日間)
feng
feng 2011 年 3 月 8 日
コメント済み: Adam Danz 2020 年 8 月 20 日
When I used scatter to plot my data, it gave markers in different shapes, but the sample indexes are important in my case and I want to put sample indexes as markers, can I do it in matlab? Thanks
  1 件のコメント
Andreas Goser
Andreas Goser 2011 年 3 月 8 日
You can increase the chances of getting a response by providing example code or a screenshot.

サインインしてコメントする。

回答 (1 件)

Andreas Goser
Andreas Goser 2011 年 3 月 8 日
The user provided details. The question is about whether you can use numbers (in this case an index) instead of a marker. I suggest using TEXT instead of SCATTER. Here I have an example code
x=[1 1 2 2 3 3 4 4];
y=[2 3 1 2 3 4 3 2];
figure(1)
scatter(x,y)
figure(2)
axis([min(x)-1, max(x)+1, min(y)-1, max(y)+1])
for k=1:length(x)
text(x(k),y(k),num2str(k))
end
  3 件のコメント
Andreas Goser
Andreas Goser 2011 年 3 月 8 日
Yeah, I know - old school still using EVAL and loops...
Adam Danz
Adam Danz 2020 年 8 月 20 日
If you're using text as markers, it probably important to center the text on the coordinate. To do that,
text(___, 'HorizontalAlignment', 'Center', 'VerticalAlignment', 'Middle')

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by