'Pyvis network keeps on moving

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?



Solution 1:[1]

You can use

G.show_buttons(filter_=['physics']) 

to manage physical parameters using sliders in the visualization.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 XavierStuvw