Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
3,280 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
*.py[cod] | ||
__pycache__ | ||
|
||
# C extensions | ||
*.so | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,53 @@ | ||
nxpd | ||
==== | ||
|
||
Pydot drawing of NetworkX graphs with support for IPython notebooks. | ||
`nxpd` is a Python package for visualizing NetworkX graphs using `pydot` | ||
and `graphviz`. Support is also provided for inline displays within IPython | ||
notebooks. | ||
|
||
Installation | ||
============ | ||
Clone this repository: | ||
|
||
git clone https://github.com/chebee7i/nxpd | ||
|
||
Move into the directory and install the package. | ||
|
||
python setup.py install | ||
|
||
Usage | ||
===== | ||
|
||
>>> import networkx as nx | ||
>>> from nxpd import draw | ||
>>> G = nx.cycle(4, create_using=nx.DiGraph()) | ||
>>> draw(G) | ||
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' | ||
>>> draw(G) | ||
|
||
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_cycle(range(4)) | ||
>>> 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') | ||
>>> draw(G) | ||
|
||
![IPython Notebook Example](images/demo.png) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from __future__ import absolute_import | ||
|
||
from .nx_pydot import draw_pydot as draw | ||
from .params import nxpdParams | ||
|
||
__all__ = ['draw', 'nxpdParams'] |
Oops, something went wrong.