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
/home/runner/work/nxviz/nxviz/nxviz/__init__.py:33: UserWarning: 
nxviz has a new API! Version 0.7.4 onwards, the old class-based API is being
deprecated in favour of a new API focused on advancing a grammar of network
graphics. If your plotting code depends on the old API, please consider
pinning nxviz at version 0.7.4, as the new API will break your old code.

To check out the new API, please head over to the docs at
https://ericmjl.github.io/nxviz/ to learn more. We hope you enjoy using it!

(This deprecation message will go away in version 1.0.)

  warnings.warn(

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")
No description has been provided for this image
nx.draw(G)
No description has been provided for this image