Skip to main content

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.5.0 introduces the NetworkX Plotter API, enabling direct visualization of NetworkX graph objects without manual JSON conversion.

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

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

Desplay Sample

JpyterLab 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

net_vis-0.5.0.tar.gz (414.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

net_vis-0.5.0-py3-none-any.whl (243.0 kB view details)

Uploaded Python 3

File details

Details for the file net_vis-0.5.0.tar.gz.

File metadata

  • Download URL: net_vis-0.5.0.tar.gz
  • Upload date:
  • Size: 414.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for net_vis-0.5.0.tar.gz
Algorithm Hash digest
SHA256 b77d201e3e7ec41c78f149416360cc1f4eaa700db7fe2da18ddf521b0ad1b97d
MD5 68801f9fe9f261c6f2abec2ec6655bae
BLAKE2b-256 2c67df07839878ee78cf2d777baf5fdc6f1a4b0cef389f54fa0d425d4cc21e13

See more details on using hashes here.

Provenance

The following attestation bundles were made for net_vis-0.5.0.tar.gz:

Publisher: release.yml on cmscom/netvis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file net_vis-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: net_vis-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 243.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for net_vis-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d2697441460cacc0c62dcbef5475c0e4545af260ac63bc70d115ed33ed74a70
MD5 5fb03b395ab3644fd3492bf60f8236e3
BLAKE2b-256 28d42cd11c41688ae9cd55d9d84120904eafda10962d295195d6483e714e299b

See more details on using hashes here.

Provenance

The following attestation bundles were made for net_vis-0.5.0-py3-none-any.whl:

Publisher: release.yml on cmscom/netvis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page