2013-05-21 37 views

回答

2

Can I put tags on the nodes?

您是指以下問題?
Drawing a network of nodes in circular formation with links between nodes

向圖中添加文本標籤的一般方法是使用text命令。請注意,它需要每個標籤的座標。還建議確保標籤不與節點重疊。

下面的例子如下this answer,並簡單地增加了一個小的徑向偏移到每個座標在該位置顯示該標籤之前:

idx = 1:numel(x); 
tags = cellstr(num2str(idx(:)), '%0d');  %// Generate string labels 
[dx, dy] = pol2cart(theta, 0.1);    %// Small radial offset 
dx = dx - 0.05 * (sign(x) < 0); 
for k = idx; 
    text(x(k) + dx(k), y(k) + dy(k), tags{k}) %// Add label 
end 

這是結果:

result1

How can I modify the connecting lines?

再次,this answer顯示瞭如何:修改ind1ind2相應地保存要連接的對(ind1ind2中的每兩個對應元素爲一對)。

舉例來說,如果你有興趣只在連接節點(1,10),(2,16),(3,23)和(6,19),請使用以下值ind1ind2

ind1 = [1 2 3 6]; 
ind2 = [10 16 23 19]; 

運行新的連接價值的代碼生成以下圖形:

result2

+0

對不起再次,在IND1 = [ 1 2 3 6]可以說話;我問,因爲我有一個關於社交圖的項目 –

+0

不,「ind1」和「ind2」是節點的索引值。 「單詞」(標籤)應該放在[單元格數組](http://www.mathworks.com/help/matlab/cell-arrays.html)標籤中。如果你在我的例子中,我已經使用複雜的單行標籤將標籤「01,02,03 ... 30」放在'tags'中,但這實際上相當於編寫'tags = {0,1,2, 3,... 30}'。你可以在'tags'中放入任何你想要的字符串,例如:'tags = {'first','second',...}' –

+0

非常感謝你......我寫代碼但是我有一個問題說錯誤:文件:social.m行:2列:39 不平衡或意外的括號或括號。 –