• Stars
    star
    223
  • Rank 177,758 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created over 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Draw interactive NetworkX graphs with Altair

nx_altair

Draw NetworkX graphs with Altair

Gitter chat

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).

More Repositories

1

phylopandas

Pandas DataFrames for phylogenetics
Python
65
star
2

jupyter_authorized_server

Experimenting with adding authorization to Jupyter Server
Jupyter Notebook
61
star
3

sphinx-pydantic

Generate Sphinx documentation from pydantic schemas
Python
33
star
4

jupyter_config_overview

How to navigate Jupyter's configuration system
Python
15
star
5

phylovega

Interactive tree visualizations in Python (powered by Vega).
Python
10
star
6

python-for-scientists

The easy way to set up Python for a scientist.
8
star
7

pyasr

Ancestral Sequence Reconstruction in Python
Python
5
star
8

jupyter_fastapi

Jupyter Server implemented using FastAPI
Python
5
star
9

yerkes

Interactive color palettes in Altair
Python
4
star
10

faces

Git demo for Jupyter interns
Python
4
star
11

GK-metadynamics

Shell
3
star
12

jupyter-data-privacy

Initial (attempt at) documentation around data privacy inside Jupyter deployments
2
star
13

bioinformatics-demo-2

Jupyter Notebook
2
star
14

kubeconf

Lightweight Python module for creating, manipulating, and editing kubeconfig files
Python
2
star
15

pymad

(WARNING: this isn't working yet!) Python implementation of MAD (minimal ancestor deviation)
Python
2
star
16

jupyter_home

A basic dashboard for multiple Jupyter frontends
Python
2
star
17

scipy-2018

"Resurrecting ancient proteins in Python" (SciPy 2018 talk by Zach Sailer)
Jupyter Notebook
2
star
18

pandas-flavor-talk

PyData SLO Talk: The easy way to write your own flavor of Pandas
Jupyter Notebook
1
star
19

shorten

Shorten any command in your terminal
Python
1
star
20

jupyter-telemetry-status

Current status of Jupyter's Telemetry System
1
star
21

hub_config

Experimental jupyterhub configs
Python
1
star
22

traitlets_paths

Traitlets module for pathlib
Python
1
star
23

finances

My personal finance tools
Python
1
star
24

gpm_plotly

Genotype-phenotype map visualizations powered by Plotly
Python
1
star
25

calpolythesis

Senior Thesis from California Polytechnic State University
Racket
1
star
26

why-dataframes

Why DataFrames? A lecture on why DataFrames were developed (targeted at bioinformatics students).
Jupyter Notebook
1
star
27

notebook_server_extension

The classic Jupyter Notebook as a server extension
JavaScript
1
star
28

nextgen-kernels-api

[EXPERIMENTAL] "next generation" kernel API for Jupyter Server
Python
1
star