Skip to main content
QUICK REVIEW

[Paper Review] Network visualizations with Pyvis and VisJS

Giancarlo Perrone, José Unpingco|arXiv (Cornell University)|Jun 2, 2020
Computational Physics and Python ApplicationsComputer Science11 citations
TL;DR

Pyvis is a Python library that enables interactive, web-based network visualization by leveraging the VisJS JavaScript library, allowing data scientists to create dynamic, customizable graph visualizations directly in Jupyter notebooks or standalone HTML applications. It abstracts low-level JavaScript coding, enabling users to define nodes, edges, and layout parameters in Python while rendering rich, interactive visualizations with features like drag-and-drop, zooming, tooltips, and physics-based layouts.

ABSTRACT

Pyvis is a Python module that enables visualizing and interactively manipulating network graphs in the Jupyter notebook, or as a standalone web application. Pyvis is built on top of the powerful and mature VisJS JavaScript library, which allows for fast and responsive interactions while also abstracting away the low-level JavaScript and HTML. This means that elements of the rendered graph visualization, such as node/edge attributes can be specified within Python and shipped to the JavaScript layer for VisJS to render. This declarative approach makes it easy to quickly explore graph visualizations and investigate data relationships. In addition, Pyvis is highly customizable so that colors, sizes, and hover tooltips can be assigned to the rendered graph. The network graph layout is controlled by a front-end physics engine that is configurable from a Python interface, allowing for the detailed placement of the graph elements. In this paper, we outline use cases for Pyvis with specific examples to highlight key features for any analysis workflow. A brief overview of Pyvis' implementation describes how the Python front-end binding uses simple Pyvis calls.

Motivation & Objective

  • To simplify interactive network visualization for data scientists using Python, particularly in Jupyter notebooks.
  • To bridge the gap between Python-based data analysis and high-performance, interactive JavaScript visualizations.
  • To provide a declarative, high-level interface for defining network graphs with rich customization of node/edge attributes.
  • To enable seamless integration with popular data science tools like NetworkX and Pandas for real-world use cases.
  • To demonstrate practical utility through end-to-end examples, such as visualizing relationships in the Game of Thrones dataset.

Proposed method

  • Pyvis uses a Python front-end binding that translates Python-defined nodes, edges, and layout parameters into JSON-compatible data structures for rendering via the VisJS JavaScript library.
  • The library leverages Jinja templating to generate HTML/JS code from Python objects, ensuring compatibility with VisJS’s declarative network definition format.
  • Node and edge attributes such as size, color, label, title (hover tooltip), position (x, y), and value (for scaling) are specified in Python and passed to VisJS for rendering.
  • Physics-based layout is controlled via VisJS’s Barnes-Hut algorithm, configurable through Pyvis’s Python interface to enable dynamic, interactive node positioning.
  • The library supports batch operations like add_nodes(), add_edges(), and add_edge() with optional weight and metadata parameters for complex network modeling.
  • Output is rendered as an interactive HTML file or embedded in Jupyter cells via an IFrame, enabling real-time exploration of network structures.

Experimental results

Research questions

  • RQ1How can interactive network visualization be made accessible to Python-based data scientists without requiring deep JavaScript expertise?
  • RQ2What is the performance and usability of a Python-to-VisJS abstraction layer for visualizing large, complex networks?
  • RQ3To what extent can Pyvis support customizable, interactive features such as tooltips, dynamic sizing, and physics-based layouts in a Jupyter environment?
  • RQ4How effectively can Pyvis integrate with existing data science stacks like Pandas and NetworkX for real-world data analysis workflows?
  • RQ5Can Pyvis enable meaningful exploration of complex relational data, such as character relationships in the Game of Thrones dataset, through interactive visualization?

Key findings

  • Pyvis successfully enables interactive, physics-based network visualization in Jupyter notebooks using only Python code, abstracting away the need for manual JavaScript or HTML coding.
  • The library supports rich customization of nodes and edges, including size scaling based on values, color coding, and hover tooltips with custom metadata such as neighbor lists.
  • Edge weights are visibly distinct in the rendered output, with thickness proportional to the weight value, enhancing interpretability of connection strength.
  • The Game of Thrones dataset example demonstrated that Pyvis can render complex, dense networks with hundreds of nodes and weighted edges, enabling interactive exploration through zooming and hovering.
  • The integration with NetworkX and Pandas allowed for efficient data transformation and network construction, showing compatibility with common data science pipelines.
  • The resulting HTML output supports full interactivity—dragging nodes, zooming, and clicking—making it suitable for both exploratory analysis and presentation.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.