How can I make this graphic?

I have this data Click here for data.
I want to know how can I make a graphic (see below). How can I connect the numbers from the first column the numbers with the second columns. And I need to make the lines connecting the points become thicker to be more links. I make this command for calc %.
maxdata = max(data(:,1:2));
counts = accumarray(data(:,1:2), 1, [maxdata(1,1), maxdata(1,2)]);
for i = 1:maxdata(1,1)
for j = 1:maxdata(1,2)
link(i,j) = counts(i,j)
end
end
somalink = sum(link(:));
porcentagem = link./somalink.*100;

답변 (1개)

Chad Greene
Chad Greene 2015년 6월 25일
편집: Chad Greene 2015년 6월 25일

1 개 추천

No need for loops. And note, when you do use loops, try to avoid using i and j as variable names--they're the imaginary unit. Overwriting i and j rarely causes a problem, but when it does it can be tough to debug.
A = [9 1 2 4;
9 2 1 2;
8 2 2 6;
6 1 3 3;
3 4 1 3;
8 2 2 8;
8 1 1 5;
6 1 2 8;
6 1 3 8;
9 3 2 9;
8 4 2 6;
1 2 1 1;
10 4 3 9;
4 2 3 9;
8 5 2 5;
5 2 2 1;
2 3 3 8;
7 3 1 1;
2 2 3 2;
3 5 2 1;
6 3 3 2;
5 5 1 3;
5 3 2 9;
3 5 3 5;
3 3 2 7];
figure
plot([1 2],A(:,1:2),'ko-','markersize',20,'linewidth',2,'markerfacecolor','w')
axis([0 3 0 11])
axis off

댓글 수: 4

Marcelo Costa
Marcelo Costa 2015년 6월 26일
편집: Marcelo Costa 2015년 6월 26일
Nice, Thanks for the tips. I would like to leave the lines thicker connections, in respect of links between the numbers? For example, between the number 10 and the fifth has five connections, I wanted to make the longest line than the others. Like this.
Image Analyst
Image Analyst 2015년 6월 26일
I don't understand. Which node (circle) are you calling #10? And which node (circle) is the fifth one? And which pair of nodes has 5 connections between them? From the first sentence, are you saying that one node and another node is connected N times, then you'd like a line connecting them to be N pixels wide, whereas if it's just connected once, the line is 1 pixel wide?
&nbsp
I don't know what you're saying about making some line longer than the others. The length is determined by the x,y coordinates of the two nodes. It is what it is, so how can you make it longer? It wouldn't touch the nodes anymore if it were a different length.
Marcelo Costa
Marcelo Costa 2015년 6월 26일
편집: Image Analyst 2015년 6월 26일
From the first sentence, are you saying that one node and another node is connected N times, then you'd like a line connecting them to be N pixels wide, whereas if it's just connected once, the line is 1 pixel wide? Yes. It is
Image Analyst
Image Analyst 2015년 6월 26일
편집: Image Analyst 2015년 6월 26일
OK, your new/edited graphic above helps explain the thickness question. Note the 'linewidth' option in plot. You'll have to plot the lines one at a time, varying the linewidth parameter for each line segment.
Now, what about the line length question? Your answer seems to have been cut off.

이 질문은 마감되었습니다.

태그

질문:

2015년 6월 25일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by