現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
how show the clusters graphically?
4 ビュー (過去 30 日間)
古いコメントを表示
hi,
I got the indices of clusters of my data. I would like to see the result with drawing. i.e I hope to see the clusters graphically.
can do that?
thanks in advance
回答 (3 件)
per isakson
2012 年 8 月 13 日
... and the statistical toolbox
3 件のコメント
huda nawaf
2012 年 8 月 13 日
thanks, I visited that link and run plotcluster: http://www.mathworks.se/matlabcentral/fileexchange/31710-plotclusters-m
but I confused with the first input of this function, the author said that the first input must be n*2 or n*3 and do not know exactly what are the elements of n*2 or n*3 if n is the number of observations , is that meaning I have to creat array with size 6*2 , because i have for examplr 6 observations and the matrix be data=[1 1;2 2 ; 3 3; 4 4; 5 5; 6 6]
I'm not sure, if that proper or not.
Walter Roberson
2012 年 8 月 13 日
Look at the Description at that link. It describes exactly what each of the parameters means.
Image Analyst
2012 年 8 月 13 日
There are no clusters in that data because your data is uniformly spaced. Or there are 6 clusters with just one point in them, or one big cluster with 6 points. You don't really have aggregation or clumping of any of the points.
Ilya
2012 年 8 月 13 日
Huda, when I answered your other question, I suggested that you run 'doc linkage' and gave you a link to the web doc for that function. At the bottom of that page, you can see examples of two different plots. Are you asking for a plot that is not on that page?
2 件のコメント
huda nawaf
2012 年 8 月 13 日
i saw , but I think scatter do not work with my case. please see comments below with image analyst
thanks
Image Analyst
2012 年 8 月 13 日
Why not just use the scatter() function? If that doesn't work, then explain why not, and use more words to do it.
31 件のコメント
huda nawaf
2012 年 8 月 13 日
I do not know what X and y represent. where i have 6 points which i need to cluster them and have vector with size 6*1 of indices of clusters for each point.
how I use scatter? there is no any indication about x and y the input of scatter function.
thanks
scatter
Image Analyst
2012 年 8 月 13 日
You can try this:
data=[1 1;2 2 ; 3 3; 4 4; 5 5; 6 6]
xData = data(:, 1);
yData = data(:, 2);
scatter(xData, yData);
but with the data example you gave, you don't have any clusters at all.
huda nawaf
2012 年 8 月 13 日
ok , i know what the result. this is why I asked what X and Y
in my case, i have 6 points , I clustered them into 3 clusters
their clusters:[ 1 2 2 3 1 3]; how I can plot then using scatter?
thanks
huda nawaf
2012 年 8 月 13 日
編集済み: Walter Roberson
2012 年 8 月 13 日
walter, of course I read it
he said that
%%% data - an m-by-d matrix, where m is the number of data points to cluster and d is the number of dimensions.%%%%
ok the size of data is m*d, m =6 in my case and d=2.
is that meaning that the no. of rows will be 6 and the no. of columns is 2 if so what are the elements of this array?
thanks
huda nawaf
2012 年 8 月 13 日
this is for image analyst,
in my case I have 6 users,each user have 6 scores that show the rate of similarity with the other user.
now what x and y?
Image Analyst
2012 年 8 月 13 日
If you know what rows are what clusters, then you can pass in different colors for each cluster into scatter(). So cluster 1, 2, and 3 would each have a different color so you can visualize them.
huda nawaf
2012 年 8 月 13 日
yes, that I that want I know the no. of cluster for each row. how I show the clusters with different color
what the inputs of scatter? thanks
Image Analyst
2012 年 8 月 13 日
Come on, you didn't even read the help for scatter() did you? It's right in there. You just pass the colors in as an argument.
huda nawaf
2012 年 8 月 13 日
simply, I have vector
x=[1 5 2 3 4 3 5 5] I need function can draw 1 as cluster with spesific color and 2 with another color, and 3,4,5 . for example cluster 5 with red color in which three samples ,and cluster 3 with different color in which two samples.
can find such function? thanks
Walter Roberson
2012 年 8 月 13 日
編集済み: Walter Roberson
2012 年 8 月 13 日
The number of rows for the first argument to "plotclusters" would be the number of observations. The columns correspond to the dimension. "plotclusters" only works with observations that are 2 or 3 dimensions. Each row of the input matrix would be one observation.
For example if the first observation were at (17.2,8.1,-33) then the first row of the input matrix would be [17.2, 8.1, -33]
huda nawaf
2012 年 8 月 13 日
編集済み: Walter Roberson
2012 年 8 月 13 日
IMAGE ALYST.
x=[1 2 3 4 5 6];%%%data points
y=[2 3 3 4 1 2];%%indices of clusters
I did that
scatter(x,y,5,'r')
wha i got are six circles with same color.
this plot is meaningless.
the data with same cluster is not grouped in addirion to they has not same color.
i.e the data points 2 and 3, how i can know they are in same cluster?
i deal with large size of data, it is important for me to see the structure of network
thanks
Walter Roberson
2012 年 8 月 13 日
scatter(x, zeros(size(x)), 5, y)
The zeros() is there to compensate for the fact that you only have a single coordinate for your data, but you need 2 coordinates in order to draw on a graph.
Image Analyst
2012 年 8 月 13 日
huda, yes you can find such a function. Like I said, the scatter() function can draw different clusters with different colors. You just need to make up the color map to reflect that. Here's a demo I wrote just for you:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
workspace; % Make sure the workspace panel is showing.
format longg;
format compact;
fontSize = 20;
numberOfPointsPerCluster = 20
% Make up 3 separated clusters.
cluster1x = 9+rand(numberOfPointsPerCluster,1);
cluster1y = 9+rand(numberOfPointsPerCluster,1);
cluster2x = 9+rand(numberOfPointsPerCluster,1);
cluster2y = 1+rand(numberOfPointsPerCluster,1);
cluster3x = 1+rand(numberOfPointsPerCluster,1);
cluster3y = 1+rand(numberOfPointsPerCluster,1);
allClustersX = [cluster1x; cluster2x; cluster3x];
allClustersY = [cluster1y; cluster2y; cluster3y];
% Make the firstr cluster red, the second green, and the third one blue.
colorMap = zeros(numberOfPointsPerCluster*3, 3);
colorMap(1:numberOfPointsPerCluster,1) = 1;
colorMap(numberOfPointsPerCluster+1:2*numberOfPointsPerCluster, 2) = 1;
colorMap(2*numberOfPointsPerCluster+1:3*numberOfPointsPerCluster, 3) = 1;
% Do the scatterplot with different colors for different clusters.
scatter(allClustersX, allClustersY, 200, colorMap, '+');
% Fancy up the chart.
xlim([0 12]);
ylim([0 12]);
grid on;
xlabel('X', 'fontSize', fontSize);
ylabel('Y', 'fontSize', fontSize);
title('3 clusters with different colors', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Give a name to the title bar.
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
huda nawaf
2012 年 8 月 14 日
thanks for your efforts. this good results
But, I need to know how I can input my data for this code to see my results
many thanks
Image Analyst
2012 年 8 月 14 日
There are a variety of methods such as load(), dlmread(), csvread(), xlsread(), fopen(), textscan(), ActiveX, using the data or image acquisition toolboxes, etc. How did you get data into your other MATLAB programs in the past? Why can't you do it the same way?
huda nawaf
2012 年 8 月 14 日
I do mean that of course I know how read my data. That always happen because poor in my language.always happen misunderstanding. what I mean which part of your code deal with data matrix or data vector? so I can adapt your code with my data.
thanks
Walter Roberson
2012 年 8 月 14 日
Everything up to and including AllClustersX and AllClustersY are part of "loading" the data for the purpose of Image Analyst's code.
huda nawaf
2012 年 8 月 14 日
I used plotcluster code , I think I got good result.
PlotClusters(Data,IDX)
where , the first input of function data is m*3 that i got it from linkage function ,but input IDX manually with size m*1. I can got IDX from cluster function but these indices of clusers for each observations (m+1 observations).
how I can get IDX for data?
thanks
Ilya
2012 年 8 月 14 日
Slightly modifying the example from the doc page I keep referring to:
X = rand(1000,2);
Z = linkage(X,'complete');
c = cluster(Z,'maxclust',4);
gscatter(X(:,1),X(:,2),c);
All you need to do is replace X = rand(1000,2) with your data and change 4 to the number of clusters you want.
huda nawaf
2012 年 8 月 14 日
thanks, but my data is square similarity matrix. I can not use just two colomns . the figure is very good but this function work just for two input. I tried it with the output of linkage function, but not get what I need. I think scatter do not work with my data.
Ilya
2012 年 8 月 14 日
I suspect no one here understands what you want to do. Could you please summarize in a few simple sentences: a) What data you have: how many arrays, what they represent, their size, and type, and b) what kind of plot you want to see.
huda nawaf
2012 年 8 月 15 日
I have n*n similarity matrix. ex. n=5 x=[0 3 4 7 8; 3 0 5 2 4; 4 5 0 10 3; 7 2 10 2 1; 8 4 3 1 0];
each row in x is represent the rate of similarity of one user with the others.So, the number of users =5 As u see , it is symmetric matrix.I did clustering for users using ward. The above is just example, my data is large dataset.
I got vector show the index of cluster that each user belong to it. for above example , the vector will be c=[2 2 3 1 3]. simply, for example if we represent each user with circle or anything the drawing will be 2 red circles(user1 and 2), two blue circles(user 3 and 5) and one green circle (user 4)
can do that?
huda nawaf
2012 年 8 月 30 日
I don't care with positions, it is enough for me the cicles be grouped.
thanks
Oleg Komarov
2012 年 8 月 30 日
With just the similarity matrix you cannot represent a scatter, but a dendogram.
Image Analyst
2012 年 8 月 31 日
Once you know the centers and radius, you can use rectangle() or check the FAQ to draw the colored circles. Try it.
Ilya
2012 年 8 月 31 日
load fisheriris
d = pdist(meas);
Z = linkage(d);
c = cluster(Z,'maxclust',4);
Y = cmdscale(d);
gscatter(Y(:,1),Y(:,2),c)
参考
カテゴリ
Help Center および File Exchange で Data Distribution Plots についてさらに検索
タグ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)