def draw_transmat_graph(G, edge_threshold=0, lw=1, ec='0.2', node_size=15):
num_states = G.number_of_nodes()
edgewidth = [ d['weight'] for (u,v,d) in G.edges(data=True)]
edgewidth = np.array(edgewidth)
edgewidth[edgewidth<edge_threshold] = 0
labels = {}
labels[0] = '1'
labels[1]= '2'
labels[2]= '3'
labels[num_states-1] = str(num_states)
npos=circular_layout(G, scale=1, direction='CW')
lpos=circular_layout(G, scale=1.15, direction='CW')
nx.draw_networkx_edges(G, npos, alpha=0.8, width=edgewidth*lw, edge_color=ec)
nx.draw_networkx_nodes(G, npos, node_size=node_size, node_color='k',alpha=0.8)
ax = plt.gca()
nx.draw_networkx_labels(G, lpos, labels, fontsize=18, ax=ax); # fontsize does not seem to work :/
ax.set_aspect('equal')
return ax
评论列表
文章目录