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
drawmethod 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).
Metadata
Release files for nx-altair 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| nx_altair-0.1.6.tar.gz | 8.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nx_altair-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.4 kB
Release files / nx_altair-0.1.6.tar.gz
| Download URL | nx_altair-0.1.6.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
17c5ba760251fc17ab49e786e93c8820fcefbe1cb2f539886651265cbdb52c63
|
|
BLAKE2b-256 checksum How to use checksums |
5e6e3a0777c9135d895d8f23223344b6218e7f291c01ff741461ace94ff25f0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / nx_altair-0.1.6-py3-none-any.whl
| Download URL | nx_altair-0.1.6-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
737c960598b405ed88882c3f1e9a0237ae4e5ba245380c8d0ec2c29fba9f1a38
|
|
BLAKE2b-256 checksum How to use checksums |
61016436e91bc44d0e65a40f46e99535def7ac02cabe34e7685c52b3e1f94e31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for nx-altair 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.