2016-04-21 50 views
0

我寫了一些代碼來顯示在jupyter筆記本中使用networkx的二分圖。我已經使用我認爲是Tex的節點來渲染節點的標籤,但是我似乎無法獲得渲染的Tex字體的大小以增加。有沒有一個簡單的方法來做到這一點?幫助會很好。Jupyter筆記本networkx tex節點字體太小

下面是我的代碼和二分圖的圖像, bipartite graph

import networkx as nx 
% matplotlib inline 
from networkx.algorithms import bipartite 
B = nx.Graph() 
B.add_nodes_from(['$x_1$','$x_2$','$x_3$'], s='o', c='#AA5555', bipartite=0) # Add the node attribute 'bipartite' 
B.add_nodes_from(['$f_a$','$f_b$','$f_c$','$f_d$'], s='s', c='#55AAAA', bipartite=1) 
B.add_edges_from([('$x_1$','$f_a$'),('$x_1$','$f_b$'),('$x_2$','$f_a$'),('$x_2$','$f_b$'),('$x_2$','$f_c$'),('$x_3$','$f_c$'),('$x_3$','$f_d$')]) 

pos = dict() 
X, Y = bipartite.sets(B) 
pos.update((n, (i,1)) for i, n in enumerate(X)) 
pos.update((n, (i+0.5,2)) for i, n in enumerate(Y)) 

disjointSetCount = 2 
for disjointSet in range(0, disjointSetCount): 
    nx.draw(
     B, 
     pos, 
     with_labels=True, 
     node_shape = 's' if disjointSet == 1 else 'o', 
     node_color = '#FFEEEE' if disjointSet==1 else '#EEEEFF', 
     node_size=1000, 
     nodelist = [ 
      sNode[0] for sNode in filter(lambda x: x[1]["bipartite"]==disjointSet, B.nodes(data=True)) 
     ] 
    ) 

plt.savefig("img/15_Graphical_Models_12b.png") # save as png 

回答

1

一個可選參數爲nx.drawfont_size。如果我設置font_size=100我得到

enter image description here

這應該是足夠大的。

+0

哇,這可能很大! –