We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should the example present at https://github.com/ericmjl/nxviz/blob/master/docs/developers/architecture.md#intended-usage-example-2 be a self contained example? A user can't just copy and paste and run this example.
Something like?
from nxviz import lines, utils, layouts, nodes, edges from nxviz.plots import despine import matplotlib.pyplot as plt import networkx as nx from random import choice import numpy as np import pandas as pd def group_colormap(data: pd.Series): cmap = {"a": "black", "b": "blue", "c": "red"} return data.apply(lambda x: cmap.get(x)) # Generate a random network and populate node and edge attributes. G = nx.erdos_renyi_graph(n=20, p=0.2) for n, d in G.nodes(data=True): G.nodes[n]["group"] = choice(["a", "b", "c"]) G.nodes[n]["value"] = np.random.exponential()/10 np.random.seed(44) for u, v, d in G.edges(data=True): G.edges[u, v]["edge_value"] = np.random.exponential() ax = plt.gca() ##### Part 1: Nodes ##### # 1. Obtain node table nt = utils.node_table(G) # 2. Obtain positions using node table. pos = layouts.circos(nt, group_by="group", sort_by="value") # 3. Obtain node styles node_color = group_colormap(nt["group"]) alpha = nodes.transparency(nt, alpha_by=None) size = nodes.node_size(nt, "value") # 4. Obtain patches styled correctly and add them to matplotlib axes. patches = nodes.node_glyphs( nt, pos, node_color=node_color, alpha=alpha, size=size ) for patch in patches: ax.add_patch(patch) ##### Part 2: Edges ##### # 1. Obtain edge table et = utils.edge_table(G) # 2. Obtain edge styling. edge_color = edges.edge_colors(et, color_by=None) lw = np.sqrt(et["edge_value"]) alpha = edges.transparency(et, alpha_by=None) # 3. Obtain edge patches styled and add them to matplotlib axes. patches = lines.circos( et, pos, edge_color=edge_color, alpha=alpha, lw=lw, aes_kw={"fc": "none"} ) for patch in patches: ax.add_patch(patch) ax.plot() despine() # remove the spines
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Should the example present at https://github.com/ericmjl/nxviz/blob/master/docs/developers/architecture.md#intended-usage-example-2 be a self contained example? A user can't just copy and paste and run this example.
Something like?
The text was updated successfully, but these errors were encountered: