Skip to main content

Interactive network in d3js

Project description

Interactive network creator (d3graph)

PyPI Version License

d3graph is a python package that simplifies the task of creating interactive and stand-alone networks in d3 javascript using python. For this package I was inspired by various examples shown on the internet. But all of these examples are purely based on javascript without any easy python package to generate the networks. Therefore I decided to create a package that automatically creates d3js javascript and html code based on a input adjacency matrix in python! Huray!

This package provides functionality to create a interactive and stand-alone network that is build on d3 javascript. D3graph only requirs an adjacency matrix in the form of an pandas dataframe. Each column and index name represents a node whereas values >0 in the matrix represents an edge. Node links are build from rows to columns. Building the edges from row to columns only matters in directed cases. The network nodes and edges can be adjusted in weight, color etc, based on user defined paramters.

Contents

Installation

d3graph is compatible with Python 3.6+ and runs on Linux, MacOS X and Windows. Note: d3graph requires networkx to be v2 or higher. It is distributed under the Apache 2.0 license. There are two ways to install d3graph:

  • Install d3graph from PyPI (recommended):
pip install d3graph
  • Install d3graph from the GitHub source:
git clone https://github.com/erdogant/d3graph.git
cd d3graph
pip install "networkx>=2"
python setup.py install

Quick Start

In order to create an interactive and stand-alone d3graph, following workflow can be used:

  • Import d3graph method
from d3graph import d3graph
  • Create simple example dataset for which the input matrix should look this:

G = nx.karate_club_graph()
adjmat = nx.adjacency_matrix(G).todense()
adjmat = pd.DataFrame(index=range(0,adjmat.shape[0]), data=adjmat, columns=range(0,adjmat.shape[0]))
adjmat.iloc[3,4]=5
adjmat.iloc[4,5]=6
  • Make d3graph
G_d3   = d3graph(adjmat)

The output looks as below:

Contribute

Citation

Please cite d3graph in your publications if this is useful for your research. Here is an example BibTeX entry:

@misc{erdogant2019d3graph,
  title={d3graph},
  author={Erdogan Taskesen},
  year={2019},
  howpublished={\url{https://github.com/erdogant/d3graph}},
}

Maintainers

© Copyright

See LICENSE for details.

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

d3graph-0.1.3.tar.gz (108.7 kB view hashes)

Uploaded Source

Built Distribution

d3graph-0.1.3-py3-none-any.whl (94.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page