How to use the nxviz.plots.MatrixPlot function in nxviz

To help you get started, we’ve selected a few nxviz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ericmjl / nxviz / examples / matrix / octahedral.py View on Github external
"""
Displays a NetworkX octahedral graph to screen using a MatrixPlot.
"""

import matplotlib.pyplot as plt
import networkx as nx

from nxviz.plots import MatrixPlot

G = nx.octahedral_graph()
c = MatrixPlot(G)
c.draw()
plt.show()
github ericmjl / nxviz / examples / matrix / barbell.py View on Github external
Displays a NetworkX barbell graph to screen using a CircosPlot.

Features of this example:
- MatrixPlot
- Styling matrix plot with different colormap.
"""

import matplotlib.pyplot as plt
import networkx as nx

from nxviz.plots import MatrixPlot

G = nx.barbell_graph(m1=10, m2=3)

# Instantiate a MatrixPlot with no custom styling.
m = MatrixPlot(G)

# Change the cmap prior to drawing.
m.cmap = plt.cm.get_cmap("Greens")
m.draw()
plt.show()
github ericmjl / nxviz / examples / matrix / lollipop.py View on Github external
"""
Displays a NetworkX lollipop graph to screen using a MatrixPlot.
"""

import matplotlib.pyplot as plt
import networkx as nx
import numpy.random as npr

from nxviz.plots import MatrixPlot

G = nx.lollipop_graph(m=10, n=4)
for n, d in G.nodes(data=True):
    G.node[n]["value"] = npr.normal()
c = MatrixPlot(G, node_color="value", node_order="value")
c.draw()
plt.show()