I'm trying to make the labels of my networkx circular graph (in python) more legible. Below is the current state of my code and visual. I'm trying to better visualize the relationships I've identified in the Market Basket Analysis I conducted.
Is there a way to make the labels more legible, or would you recommend a different method to visualize the data altogether? Thanks!
G = nx.from_pandas_edgelist(df4, 'antecedents', 'consequents')
nx.draw(G, with_labels=True, node_size=100, node_color="skyblue", pos=nx.circular_layout(G))
plt.figure(figsize=(50,50))
It is hard to analyze your graph, but looks like circular layout is not good for it. For example:
import networkx as nx
G = nx.fast_gnp_random_graph(50, 0.05)
nx.draw(G, pos=nx.circular_layout(G), node_size=50)
And spring layout for exactly this graph:
nx.draw(G, pos=nx.spring_layout(G), node_size=50)
Shows a far better visualization.
But if you really need circular layout for your graph, you can use some tricks from my another answer:
How to improve network graph visualization?
That will force matplotlib
to draw the graph on the huge image surface:
import networkx as nx
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(40, 40))
G = nx.fast_gnp_random_graph(300, 0.02, seed=1337)
nx.draw(G, node_size=30)
plt.axis('equal')
plt.show()
fig.savefig('waka.svg')