NetVis is a package for interactive visualization of Python NetworkX graphs within JupyterLab. It leverages D3.js for dynamic rendering and provides a high-level Plotter API for effortless network analysis.
Project description
netvis
NetVis is a package for interactive visualization of Python NetworkX graphs within JupyterLab. It leverages D3.js for dynamic rendering and provides a high-level Plotter API for effortless network analysis.
Version 0.6.0 adds standalone HTML export, enabling you to share visualizations as self-contained HTML files that work anywhere—no JupyterLab or internet connection required.
Installation
Basic Installation
You can install using pip:
pip install net_vis
This provides core functionality with layouts: spring, circular, and random.
Full Installation (Recommended)
For all layout algorithms including kamada_kawai and spectral:
pip install net_vis[full]
This installs optional dependencies (scipy) required for advanced layout algorithms.
Note: NetVis uses a MIME renderer that works automatically in JupyterLab 3.x and 4.x environments. No manual extension enabling is required.
Quick Start
NetworkX Plotter API (New in v0.5.0)
The easiest way to visualize NetworkX graphs in JupyterLab:
from net_vis import Plotter
import networkx as nx
# Create a NetworkX graph
G = nx.karate_club_graph()
# Visualize with one line
plotter = Plotter(title="Karate Club Network")
plotter.add_networkx(G)
Custom Styling
Control node colors, labels, and layouts:
# Color nodes by attribute, customize labels
plotter = Plotter(title="Styled Network")
plotter.add_networkx(
G,
node_color="club", # Use 'club' attribute for colors
node_label=lambda d: f"Node {d.get('name', '')}", # Custom labels
edge_label="weight", # Show edge weights
layout='kamada_kawai' # Choose layout algorithm
)
Supported Features
- Graph Types: Graph, DiGraph, MultiGraph, MultiDiGraph
- Layouts: spring (default), kamada_kawai, spectral, circular, random, or custom functions
- Styling: Attribute-based or function-based color/label mapping
- Automatic: Node/edge attribute preservation in metadata
HTML Export (New in v0.6.0)
Export your visualizations as standalone HTML files:
# Export to file
path = plotter.export_html("my_graph.html")
print(f"Exported to {path}")
# Export with customization
plotter.export_html(
"report.html",
title="Network Analysis Report",
description="Generated from NetworkX graph",
width="800px",
height=700
)
# Get HTML as string for embedding
html = plotter.export_html()
The exported HTML files:
- Work offline (no internet required)
- Include all interactive features (zoom, pan, node selection)
- Are self-contained (no external dependencies)
- Open in any modern browser
One-Click Download Button (New in v0.6.0)
When viewing a graph in JupyterLab, you'll see a download button in the top-right corner of the visualization. Click it to instantly download the graph as a standalone HTML file:
- No code needed: Just click the button
- Works offline: Button works even if the kernel is stopped
- Auto-named: Files are saved as
netvis_export_YYYY-MM-DD.html
| Use Case | Method |
|---|---|
| Quick download | Click the download button |
| Custom filename | plotter.export_html("my_name.html") |
| Programmatic export | html = plotter.export_html() |
Low-Level API (Advanced)
For manual control over the visualization data structure:
import net_vis
data = """
{
"nodes": [
{
"id": "Network"
},
{
"id": "Graph"
}
],
"links": [
{
"source": "Network",
"target": "Graph"
}
]
}
"""
w = net_vis.NetVis(value=data)
w
When executed, an interactive D3.js force-directed graph is displayed.
- Display Sample
Development Installation
Create a dev environment:
python -m venv venv-netvis
source venv-netvis/bin/activate
Install the Python package. This will also build the TypeScript package:
pip install -e ".[test, examples, docs]"
Install JavaScript dependencies and build the extension:
yarn install
jupyter labextension develop --overwrite .
yarn run build
Note: As of version 0.4.0, nbextension support has been removed. NetVis now exclusively uses the MIME renderer architecture for JupyterLab 3.x and 4.x.
How to see your changes
TypeScript:
If you use JupyterLab to develop, you can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.
# Watch the source directory in one terminal, automatically rebuilding when needed
yarn run watch
# Run JupyterLab in another terminal
jupyter lab
After a change, wait for the build to finish and then refresh your browser and the changes should take effect.
Python:
If you make a change to the Python code, you will need to restart the notebook kernel to have it take effect.
Contributing
Contributions are welcome!
For details on how to contribute, please refer to CONTRIBUTING.md.
Special Thanks
This project was initiated on the proposal of Shingo Tsuji. His invaluable contributions —from conceptual planning to requirements definition— have been instrumental in bringing this project to fruition. We extend our deepest gratitude for his vision and support.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file net_vis-0.6.0.tar.gz.
File metadata
- Download URL: net_vis-0.6.0.tar.gz
- Upload date:
- Size: 633.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef162df3f475e8ff0a99c33ffed623dabdc7ba98eae317ec493e0b8140230b6e
|
|
| MD5 |
f3a634341c747a27c574296e44c403fa
|
|
| BLAKE2b-256 |
8d2d433416912ad64200f5861ab8e466c1cc71549a16c02e2e227b5990541de2
|
Provenance
The following attestation bundles were made for net_vis-0.6.0.tar.gz:
Publisher:
release.yml on cmscom/netvis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
net_vis-0.6.0.tar.gz -
Subject digest:
ef162df3f475e8ff0a99c33ffed623dabdc7ba98eae317ec493e0b8140230b6e - Sigstore transparency entry: 779463592
- Sigstore integration time:
-
Permalink:
cmscom/netvis@ef6f2cf2270309a953a5f971ad0dac38b81080a4 -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/cmscom
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ef6f2cf2270309a953a5f971ad0dac38b81080a4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file net_vis-0.6.0-py3-none-any.whl.
File metadata
- Download URL: net_vis-0.6.0-py3-none-any.whl
- Upload date:
- Size: 527.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0c39b2458ebeb686030d7dc5af2bb3f86fb49b93c7cfc8261462c9a42ea6851
|
|
| MD5 |
9172e2d28a9aeb7c4fdaa3f09ff09401
|
|
| BLAKE2b-256 |
1bea6fdf1edacecd9b78c8c765fa54a1970c3e37a802f6352b014db441d106d1
|
Provenance
The following attestation bundles were made for net_vis-0.6.0-py3-none-any.whl:
Publisher:
release.yml on cmscom/netvis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
net_vis-0.6.0-py3-none-any.whl -
Subject digest:
e0c39b2458ebeb686030d7dc5af2bb3f86fb49b93c7cfc8261462c9a42ea6851 - Sigstore transparency entry: 779463593
- Sigstore integration time:
-
Permalink:
cmscom/netvis@ef6f2cf2270309a953a5f971ad0dac38b81080a4 -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/cmscom
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ef6f2cf2270309a953a5f971ad0dac38b81080a4 -
Trigger Event:
push
-
Statement type: