Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
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()
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()
"""
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()