Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transparent Networx Edge Labels

How to set transparent edge labels in NetworkX graph? Currently there is a white background to each label which cuts my edges and overlaps other labels

nx.draw(v29graph,
        nx.get_node_attributes(v29graph,'pos'),
        edge_labels=labels2
        )

nx.draw_networkx_edge_labels(v29graph,
                             pos=nx.get_node_attributes(v29graph,'pos'),
                             edge_labels=labels2
                             )
like image 762
Ankit Goel Avatar asked Mar 01 '17 04:03

Ankit Goel


People also ask

How do I add labels to edges in NetworkX?

You can use draw_networkx_edge_labels(edge_labels) to draw label between edges. If edge_labels is not given, the attributes of edge is used. edge_labels should be a dictionary keyed by edge two-tuple of text labels. Only labels for the keys in the dictionary are drawn.

How do you draw a directed graph using NetworkX in Python?

1. How to draw directed graphs using NetworkX in Python? ​ By using the base class for directed graphs, DiGraph(), we are able to draw a directed graph with arrows to indicate the direction of edges.


1 Answers

You can use the bbox argument:

nx.draw_networkx_edge_labels(v29graph,
                             pos=nx.get_node_attributes(v29graph,'pos'),
                             edge_labels=labels2, 
                             bbox=dict(alpha=0)
                             )

More bbox style examples are here.

like image 69
max Avatar answered Oct 14 '22 14:10

max