Skip to content

Binder

Matrix Plot

Here is an example of how to create a matrix plot.

%config InlineBackend.figure_format = 'retina'
%load_ext autoreload
%autoreload 2
import matplotlib.pyplot as plt
import networkx as nx
import numpy.random as npr

import nxviz as nv
G = nx.lollipop_graph(m=10, n=4)
for n, d in G.nodes(data=True):
    G.nodes[n]["degree"] = nx.degree(G, n)
ax = nv.matrix(G, sort_by="degree", node_color_by="degree")
nx.draw(G)