フィルターのクリア

How do i using scatter plot in matlab to plot 2D or 3D data with new labels ?

1 回表示 (過去 30 日間)
ahmed obaid
ahmed obaid 2017 年 2 月 9 日
コメント済み: Star Strider 2017 年 2 月 9 日
Dear experiences
i have a dataset stored in an excel file, where data has labels from A1..An as in the following:
states Dim1 Dim2 part
A27 0.000961859 0.030987232 1
A127 0.015515794 0.047256875 1
A34 0.063094311 -0.188401909 2
A47 0.069889903 -0.162175315 2
A12 -0.351944163 -0.092892019 3
A112 0.108680014 -0.297203971 4
My questions are :
  1. How i can using scatter plot in matlab to plot the above labels as in the attached figure?
  2. Is there any option to plot every collection of points with distinct color like ( part1=black, part2=red, etc. )?
  3. fianlly, i need to create labels for every collection, my labels are part1, part2, part3, part4) based on my dataset, so i hope to this property can be performed based on Dim1 and Dim2 values range.
thanks for any suggestion.
  4 件のコメント
KSSV
KSSV 2017 年 2 月 9 日
Then do you have these Ai's separately for each cluster?
ahmed obaid
ahmed obaid 2017 年 2 月 9 日
Yes, i have it.. but i would like to plotting it according to its x,y values..

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

採用された回答

Star Strider
Star Strider 2017 年 2 月 9 日
This will get you started:
[D,S] = xlsread( . . . );
D = [-0.005859903 0.003131757
-0.009648814 0.001774854
-0.006499227 0.003332951
-0.007080218 0.00482714];
S = {'A1'
'A2'
'A3'
'A4'};
figure(1)
text(D(:,1), D(:,2), S, 'FontSize',8)
axis([min(D(:,1)) max(D(:,1)) min(D(:,2)) max(D(:,2))])
  2 件のコメント
ahmed obaid
ahmed obaid 2017 年 2 月 9 日
Very good point, i have modified my question also,now i created a new columns contain the labels for my data, so how to plot points in similar part with color differ from other part, where part is a columns can contain any values. thanks
Star Strider
Star Strider 2017 年 2 月 9 日
Rather than rewrite the data, I added a couple points and changed the code to provide different coloured markers for the various values of ‘part’.
This works:
D = [-0.005859903 0.003131757 1
-0.009648814 0.001774854 2
-0.006499227 0.003332951 3
-0.007080218 0.00482714 4
-0.351944163 -0.092892019 3
0.108680014 -0.297203971 4];
S = {'A1'
'A2'
'A3'
'A4'
'A12'
'A112'};
figure(1)
hs = scatter(D(:,1), D(:,2), 50, D(:,3), 'filled')
text(D(:,1)+0.001, D(:,2), S, 'FontSize',7, 'HorizontalAlignment','left')
set(hs, 'Marker', 's')
axis([min(D(:,1))-0.001 max(D(:,1))+0.001 min(D(:,2))-0.001 max(D(:,2))+0.001])
You will have to experiment to get the results you want with your data.

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

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by