이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
how show the clusters graphically?
조회 수: 3 (최근 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!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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 (한국어)