Draw NetworkX graphs using pydot/graphviz, with support for IPython notebooks.
Switch branches/tags
Clone or download
chebee7i Bumping to version 0.2.0.
Support for Networkx 1.9ish and default openers for Python 3.
Latest commit a0797cd Jun 13, 2016
Type Name Latest commit message Commit time
Failed to load latest commit information.
images Updated demo image. Sep 12, 2013
nxpd Bumping to version 0.2.0. Jun 14, 2016
.gitignore Initial implementation. Sep 11, 2013
LICENSE.txt Rename license. Dec 13, 2014
MANIFEST.in Whoops, simple fix. Dec 13, 2014
README.md Update README to use PyPI. Dec 13, 2014
setup.cfg Whoops, simple fix. Dec 13, 2014
setup.py Bumping to version 0.2.0. Jun 14, 2016



nxpd is a Python package for visualizing NetworkX graphs using pydot and graphviz. Support is also provided for inline displays within IPython notebooks.


Installation is easy:

pip install nxpd

Alternatively, you can use git:

git clone https://github.com/chebee7i/nxpd

Then, move into the nxpd directory and install the old fashioned way:

python setup.py install


Basic usage is as follows:

import networkx as nx
from nxpd import draw
G = nx.cycle_graph(4, create_using=nx.DiGraph())

This will display a PNG (by default) using your operating system's default PNG viewer. Alternatively, if you are in an IPython notebook, then you might like the image displayed inline. This is achieved by setting the show parameter of the draw function.

draw(G, show='ipynb')

If you want all graphs to be drawn inline, then you can set a global parameter.

from nxpd import nxpdParams
nxpdParams['show'] = 'ipynb'

Any graph/node/edge attribute that is supported by DOT is passed through to graphviz (via pydot). All others are skipped.

G = nx.DiGraph()
G.graph['rankdir'] = 'LR'
G.graph['dpi'] = 120
G.add_node(0, color='red', style='filled', fillcolor='pink')
G.add_node(1, shape='square')
G.add_node(3, style='filled', fillcolor='#00ffff')
G.add_edge(0, 1, color='red', style='dashed')
G.add_edge(3, 3, label='a')

IPython Notebook Example