Month: November 2020

Displaying a network chart graph diagram on a Django site

There is often a case for improving the understanding of things with visualisations.
Python provides a number of libraries to create great visualisations - however they often are focused more on a data science approach - scripts and jupyter notebooks.

What we want is the visualisations to be easily accessible through a django website, that is what I will be showing in this post with a specific focus on network diagrams.

What Visualisation Package are we using for the Network Graph

I have tried to find a few packages for creating a network graph:


I will be using graphviz and networkx for very simple rudementary network graphs. You can make them look good but it is strenuous effort.

I will let you try networkx with plotly and igraph on your own.


Graphviz was very simple output and input. Not too much fuss and can render in many formats. To create a simple graph displayed on the frontend as an SVG:

from graphviz import Graph

g = Graph(

g.node('root', shape='rectangle', width='1.5')

g.edge('root', 'red', label='to_red')
g.edge('root', 'blue', label='to_blue')

context_data['my_chart'] = g.pipe().decode('utf-8')

Display on frontend:

{{ my_chart | safe }}

The image output:



NetworkX is not primarily a graph drawing package but basic drawing with Matplotlib as well as an interface to use the open source Graphviz software package are included.

The networkx plot is drawn using matplotlib (it can also use graphviz) to draw.

    import matplotlib.pyplot as plt
    import networkx as nx
    import io

    G = nx.Graph()

    # rectanle width 1.5

    # label: to_red
    G.add_edge('root', 'red')
    # label: to_blue
    G.add_edge('root', 'blue')

    buf = io.BytesIO()
    plt.savefig(buf, format='svg', bbox_inches='tight')
    image_bytes = buf.getvalue().decode('utf-8')

    context_data['my_chart'] = image_bytes

Display on frontend:

{{ my_chart | safe }}

The image output:


No annotations...

Make sure you close the plot otherwise it will cause issues, matplotlib is not thread safe...


  • nx.draw(G) - draws with no labels
  • nx.draw_networkx(G) - Draws with labels


Install Lightweight Bitcoin Core on Ubuntu

  1. Get a dedicated piece of generic hardware like a raspberry pi or old laptop or tower. Use it solely for bitcoin purposes.

  2. Install ubuntu (after verifying its SHA256 HASH)

  3. Download bitcoin core

    cd /opt
    sudo wget
    # verify
    sudo wget
    sha256sum bitcoin-0.20.1-x86_64-linux-gnu.tar.gz
    cat SHA256SUMS.asc 
    # Ensure it matches
    # Install
    sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-0.20.1/bin/*