Hello,
I am not able to get arrows for my network graph. Below is my code
def network_graph(value1,value2):
network_dff=master_dictionary[value1]['network_graph']
n_Df=network_dff[network_dff['y']==value2]
G=nx.DiGraph(directed=True)
G=nx.from_pandas_edgelist(n_Df, 'y', 'combined',edge_attr='C')
edge_labels=dict([((u,v,),d['C']) for u,v,d in G.edges(data=True)])
pos=nx.spring_layout(G,seed=1)
#nx.draw_networkx_edges(G, pos, edgelist=edge_labels,arrows=True,)
nx.draw_networkx_edges(G, pos,edgelist=edge_labels,arrows=True,arrowstyle='->',arrowsize=10)
Xn=[pos[k][0] for k in pos]
Yn=[pos[k][1] for k in pos]
labels = [k for k in pos]
trace_nodes=dict(type='scatter',
x=Xn,
y=Yn,
mode='markers + text',
marker=dict(size=28, color='#99ffcc'), ##nodes size #28
text=labels,
hoverinfo='text',
textfont=dict(size=15, color='#663300')) #nodes text size #15
Xe=[]
Ye=[]
xt = []
yt = []
for e in G.edges():
mid_edge = 0.5*(pos[e[0]]+pos[e[1]])# mid point of the edge e
xt.append(mid_edge[0])
yt.append(mid_edge[1])
Xe.extend([pos[e[0]][0], pos[e[1]][0], None])
Ye.extend([pos[e[0]][1], pos[e[1]][1], None])
labels1= [edge_labels[k] for k in edge_labels]
trace_edges=dict(type='scatter',
mode='lines',
x=Xe,
y=Ye,
text=labels1, #change2
textfont=dict(size=10, color='#002266'), #change1 #text size #18
hoverinfo='skip',
line=dict(width=1, color='rgb(25,25,25)',dash='dash'))
trace_text = go.Scatter(x=xt, y=yt,
mode='text',
marker=dict(size=18, color='rgb(25,25,25)'), #20 ##edge text size
text=labels1,
textfont=dict(size=15, color='#002266'), #18 ##edge text size
textposition='bottom center', hoverinfo='text',
orientation='h')
axis=dict(showline=False,zeroline=False,showgrid=False,showticklabels=False,title='' )
layout=dict( #title= 'Network Graph',
font= dict(family='Balto'),
width=660, #850
height=400,
autosize=True,
showlegend=False,
xaxis=dict(visible=False),
yaxis=dict(visible=False),
hovermode='closest',
plot_bgcolor='#ffffff',)#set background color
fig = go.Figure(data=[trace_edges, trace_nodes, trace_text], layout=layout)
### NETWORK GRAPH 2 ######
fig2=network_graph2(network_dff,value2)
if data is None:
raise PreventUpdate
print('PRINT3_NETWORK_GRAPH')
return(fig,fig2)