I have a text corpus for which I want to visualize the co-occurence of words as a network.
To do so, I have created a pd Dataframe cooc_pd
with the columns Source
,Target
and Weight
. The first two are nodes and Weight
indicates how often the two nodes (words) occur within a set window_size.
Then, I use the following code to plot a network:
import networkx as nx
from pyvis.network import Network
import pandas as pd
G = nx.from_pandas_edgelist(cooc_pd,
source = 'Source',
target = 'Target',
edge_attr='Weight')
net = Network(notebook=True)
net.from_nx(G)
net.show("example.html")
If I choose a low threshold for weight inclusion, many connections are shown in the graph. However, in that case the nodes in the example.html
are constantly moving and interpretation is difficult. Is there a way (other then increasing the threshold) to make the nodes stop moving?