Pyvis Network Visualization Library

0.3.2 · active · verified Sat Apr 11

Pyvis is a Python library designed for the quick generation of interactive network graphs with minimal Python code. It acts as a wrapper around the popular JavaScript Vis.js library, enabling users to build graphs in Python, customize nodes and edges with various properties, and export them as interactive HTML files. The library is currently at version 0.3.2 and maintains an active development status with regular updates, including a significant 0.3.0 release that merged an experimental branch and added features like node/edge filtering from the web interface.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a basic interactive network graph using Pyvis. It initializes a `Network` object, adds three nodes with custom labels, titles, and colors, then connects them with edges. Finally, it generates an HTML file (`basic_network.html`) that can be opened in a browser to interact with the visualization. The `notebook=False` parameter ensures it generates a standalone HTML file.

from pyvis.network import Network

# Create a Network object
net = Network(height="750px", width="100%", bgcolor="#222222", font_color="white", notebook=False)

# Add nodes
net.add_node(1, label="Node 1", title="This is node 1")
net.add_node(2, label="Node 2", title="This is node 2", color="#00ff1e")
net.add_node(3, label="Node 3", title="This is node 3")

# Add edges
net.add_edge(1, 2, title="connects 1 and 2")
net.add_edge(2, 3, title="connects 2 and 3", value=5)

# Generate and save the network visualization to an HTML file
net.show("basic_network.html")

view raw JSON →