给出如下数据框:
df = pd.DataFrame({'id_emp':[13524791000109, 12053850000137, 4707821000113, 4707821000112,4707821000114, 5707821000114 ],
'name_dep': ['DIONILSO MATEUS MARCON', 'JOSE AUGUSTO ROSA', 'LUCIO ANTONIO MOSQUINI', 'DIEGO ALVES','BRUNO HENRIQUE', 'GABRIEL BARBOSA'],
'classification_roi':['very bad', 'bad', 'medium', 'good', 'very good', 'very good']
})
我可以使用以下代码使用networkx生成网络:
plt.rcParams.update({
'figure.figsize': (10,10),
'axes.spines.right': True,
'axes.spines.left': True,
'axes.spines.top': True,
'axes.spines.bottom': True})
G = nx.Graph()
G.add_nodes_from([a for a in df.index])
for ie in set(df['id_emp']):
indices = df[df['id_emp'] == ie].index
G.add_edges_from(it.product(indices, indices))
for cr in set(df['classification_roi']):
indices = df[df['classification_roi']==cr].index
G.add_edges_from(it.product(indices, indices))
color_mapping = {'very bad': 250,
'bad':50,
'medium':1,
'good': 150,
'very good': 300 }
pos = nx.kamada_kawai_layout(G)
plt.figure(figsize=(5,5))
nx.draw(G,pos,node_size = 100, width = 0.5,node_color=df['classification_roi'].replace(color_mapping),with_labels=False,
cmap='RdYlBu', vmin=0, vmax=300)
plt.show()
如何使用classification_roi
的5个可能值创建标题?