I am trying to plot a network, but I face 2 issues I couldnt resolve:

  1. the edge labels are on top of the edges (no white “spacing” no matter what I tried)
  2. improve the position of the node label (so it will match the size of the node)

see the following image of the current issue:
edge labels on top of the edges

The code I use:

plt.figure(figsize=(50, 50))
pos = nx.circular_layout(sub_graph)
labels = nx.get_edge_attributes(sub_graph, 'weight')
node_states = nx.get_node_attributes(sub_graph, 'boards')
state_pos = {n: (x + 0.15, y + 0.08) for n, (x, y) in pos.items()}
nx.draw_networkx_labels(sub_graph, state_pos, labels=node_states, font_color='red')
nx.draw_networkx_edge_labels(sub_graph, pos, label_pos=0.25, edge_labels=labels, font_weight='bold', font_size=15, clip_on=True)
nx.draw_networkx(sub_graph, pos, with_labels=True, node_color=color_map, node_size=500, alpha=0.7)

Any advice on how to solve these issues?