A small utility to visualize NetworkX graphs as Datawrapper scatterplots. This tool helps transform your graph data into interactive, visually appealing scatterplots using Datawrapper.
-
Clone this repository:
git clone https://github.com/jfreyberg/nx2dw.git cd nx2dw
-
Import the nx2dw class:
from nx2dw import nx2dw
-
Initialize the client with your Datawrapper API token (chart write rights required):
client = nx2dw(ACCESS_TOKEN, TEAM_ID, FOLDER_ID)
- Replace ACCESS_TOKEN with your API token.
- TEAM_ID and FOLDER_ID are optional parameters for organizing your output.
-
Create a visualization from a NetworkX graph:
chart_id = client.create_datawrapper_graph(networkx_graph_object)
You can customize the network by passing additional arguments to create_datawrapper_graph
.
For details, see the source code.
Refer to the example usage script for more insights.
After generating the network you can further customize and edit it in the Datawrapper editor.
Here's an example of what you can create with this tool:
Data is from Kaggle: Star Wars Social Network
This tool was originally created to generate a network for my blog post Social (and other) networks in Datawrapper.