https://github.com/neo4j/python-graph-visualization
A Python package for creating interactive graph visualizations
https://github.com/neo4j/python-graph-visualization
data-visualization graph-visualization graphs jupyter-notebooks python visualization
Last synced: about 1 month ago
JSON representation
A Python package for creating interactive graph visualizations
- Host: GitHub
- URL: https://github.com/neo4j/python-graph-visualization
- Owner: neo4j
- License: other
- Created: 2024-11-11T08:40:40.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-02-06T14:33:54.000Z (about 2 months ago)
- Last Synced: 2026-02-07T22:23:19.893Z (about 2 months ago)
- Topics: data-visualization, graph-visualization, graphs, jupyter-notebooks, python, visualization
- Language: Python
- Homepage: https://neo4j.com/docs/nvl-python/preview/
- Size: 16.5 MB
- Stars: 46
- Watchers: 7
- Forks: 10
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Graph Visualization for Python by Neo4j
[](https://pypi.org/project/neo4j-viz/)
[](https://pypi.org/project/neo4j-viz/)

[](https://neo4j.com/docs/python-graph-visualization/)
[](https://discord.gg/neo4j)
[](https://community.neo4j.com)
[](https://pypi.org/project/neo4j-viz/)
`neo4j-viz` is a Python package for creating interactive graph visualizations.
The `render` method returns an `IPython.display.HTML` object that can be viewed directly in a Jupyter Notebook or Streamlit application.
For an interactive widget experience, use `render_widget()` which returns an anywidget-based `GraphWidget` with two-way data sync.
Alternatively, you can export the output to a file and view it in a web browser.
The package wraps the [Neo4j Visualization JavaScript library (NVL)](https://neo4j.com/docs/nvl/current/).

## Some notable features
- Easy to import graphs represented as:
- projections in the Neo4j Graph Data Science (GDS) library
- graphs from Neo4j query results
- pandas DataFrames
- Node features:
- Sizing
- Colors
- Captions
- Pinning
- On hover tooltip
- Relationship features:
- Colors
- Captions
- On hover tooltip
- Graph features:
- Zooming
- Panning
- Moving nodes
- Using different layouts
- Additional convenience functionality for:
- Resizing nodes, optionally including scale normalization
- Coloring nodes based on a property
- Toggle whether nodes should be pinned or not
Please note that this list is by no means exhaustive.
## Getting started
### Installation
Simply install with pip:
```sh
pip install neo4j-viz
```
### Basic usage
We will use a small toy graph representing the purchase history of a few people and products.
We start by instantiating the [Nodes](https://neo4j.com/docs/nvl-python/preview/api-reference/node.html) and
[Relationships](https://neo4j.com/docs/nvl-python/preview/api-reference/relationship.html) we want in our graph.
The only mandatory fields for a node are the "id", and "source" and "target" for a relationship.
But the other fields can optionally be used to customize the appearance of the nodes and relationships in the
visualization.
Lastly we create a
[VisualizationGraph](https://neo4j.com/docs/nvl-python/preview/api-reference/visualization-graph.html) object with the
nodes and relationships we created, and call its `render` method to display the graph.
```python
from neo4j_viz import Node, Relationship, VisualizationGraph
nodes = [
Node(id=0, size=10, caption="Person"),
Node(id=1, size=10, caption="Product"),
Node(id=2, size=20, caption="Product"),
Node(id=3, size=10, caption="Person"),
Node(id=4, size=10, caption="Product"),
]
relationships = [
Relationship(
source=0,
target=1,
caption="BUYS",
),
Relationship(
source=0,
target=2,
caption="BUYS",
),
Relationship(
source=3,
target=2,
caption="BUYS",
),
]
VG = VisualizationGraph(nodes=nodes, relationships=relationships)
VG.render()
```
This will return an `IPython.display.HTML` object that can be rendered in a Jupyter Notebook or Streamlit application.
For an interactive Jupyter widget, use `VG.render_widget()` instead.
Please refer to the [documentation](https://neo4j.com/docs/nvl-python/preview/) for more details on the API and usage.
### Examples
For some Jupyter Notebook and streamlit examples, checkout the [/examples](/examples) directory.
## Contributing
If you would like to contribute to this project, please follow our [Contributor Guidelines](./CONTRIBUTING.md).