Last active
July 19, 2022 03:36
-
-
Save russelljjarvis/8ea6be83dc02e4a5bbaa7a023d4ad986 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Install from: | |
# https://geomdata.gitlab.io/hiveplotlib/basic_usage.html | |
## | |
from hiveplotlib import hive_plot_n_axes | |
from hiveplotlib.converters import networkx_to_nodes_edges | |
from hiveplotlib.viz import hive_plot_viz_mpl | |
from matplotlib.lines import Line2D | |
import networkx as nx | |
import numpy as np | |
# Make networkx graph object out of the different layers of the brian2 network. | |
def get_networkx_from_brian2(brian2_network): | |
for ind,layer in enumerate(brian2_network): | |
nxobj = nx.from_numpy(layer.attributes) | |
if ind>0: | |
Composed = nx.compose(G,H) | |
return Composed | |
nxobj = get_networkx_from_brian2(brian2_network) | |
nodes, edges = networkx_to_nodes_edges(nxobj) | |
# not concerned with on-axis patterns, place nodes on axes randomly | |
np.random.seed(0) | |
for node in nodes: | |
node.add_data(data=dict(val=np.random.uniform())) | |
hp = hive_plot_n_axes(node_list=nodes, edges=edges, | |
axes_assignments=splits, | |
sorting_variables=["val"]*int(len(splits)), | |
all_edge_kwargs=dict(c="C1", alpha=1), | |
repeat_edge_kwargs=dict(c="darkgrey")) | |
#repeat_axes=[True]*int(len(splits))) | |
fig, ax = hive_plot_viz_mpl(hp, c="C0") | |
fig.savefig("hive_plot_compiler.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment