Draw NetworkX graphs with Altair
Project description
nx_altair
Draw NetworkX graphs with Altair
nx_altair offers a similar draw API to NetworkX but returns Altair Charts instead.
If you'd like to contribute, join the Gitter chatroom and share your ideas! Also, checkout the to-do list below.
Examples
If you'd like to start playing with nx_altair, download this notebook!
Simple graph
import networkx as nx
import nx_altair as nxa
# Generate a random graph
G = nx.fast_gnp_random_graph(n=20, p=0.25)
# Compute positions for viz.
pos = nx.spring_layout(G)
# Draw the graph using Altair
viz = nxa.draw_networkx(G, pos=pos)
# Show it as an interactive plot!
viz.interactive()
Leverage Altair
Customize the visualization
nx_altair also supports many of the same arguments from NetworkX for styling your network--with an Altair twist! Map visualization attributes in a declarative manner.
import numpy as np
# Add weights to nodes and edges
for n in G.nodes():
G.nodes[n]['weight'] = np.random.randn()
for e in G.edges():
G.edges[e]['weight'] = np.random.uniform(1, 10)
# Draw the graph using Altair
viz = nxa.draw_networkx(
G, pos=pos,
node_color='weight',
cmap='viridis',
width='weight',
edge_color='black',
)
# Show it as an interactive plot!
viz.interactive()
Install
To install from PyPI:
pip install nx_altair
To install for development, clone this repos and install using pip
pip install -e .
Contributing
We welcome pull requests! If you find a bug, we'd love for you to submit a PR. If you're not sure how to do that, check out this simple guide.
If you have a feature request, please open an issue or submit a PR!
Todo list
A list of things to-do (good ideas for PRs).
- Add
draw
method that mirrors networkx (easy) - Node color scale vmix, vmax (easy)
- Edge color scale vmix, vmax (easy)
- Node labels (medium)
- Edge labels (medium)
- Mouse-hover interactivity (medium)
- Arrows for edges (hard)
- Support for large (>1000 edge) networks (hard)
- Force-directed interactivity (very hard---beyond altair's current 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
File details
Details for the file nx_altair-0.1.6.tar.gz
.
File metadata
- Download URL: nx_altair-0.1.6.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17c5ba760251fc17ab49e786e93c8820fcefbe1cb2f539886651265cbdb52c63 |
|
MD5 | 9f4fe6f5bedd95bf04ffbe0b004db1e6 |
|
BLAKE2b-256 | 5e6e3a0777c9135d895d8f23223344b6218e7f291c01ff741461ace94ff25f0f |
File details
Details for the file nx_altair-0.1.6-py3-none-any.whl
.
File metadata
- Download URL: nx_altair-0.1.6-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 737c960598b405ed88882c3f1e9a0237ae4e5ba245380c8d0ec2c29fba9f1a38 |
|
MD5 | f3b1d7df7a92a9316fd5ba1972af0591 |
|
BLAKE2b-256 | 61016436e91bc44d0e65a40f46e99535def7ac02cabe34e7685c52b3e1f94e31 |