ericmjl / nxviz

Visualization Package for NetworkX
https://ericmjl.github.io/nxviz
MIT License
457 stars 87 forks source link

Customize node size and colormap in circosplot #690

Open ViniciusLima94 opened 2 years ago

ViniciusLima94 commented 2 years ago

Description

I'm trying to change the node size according to an attribute of my NetworkX object but even if I set node_size="attribute", the size remains invariant.

Also, I would like to change the colormaps for edge/node attributes, but I don't see how to do it.

What I Did

# Creating a graph
G = nx.from_numpy_matrix(adj)

# Removing self-loops
G.remove_edges_from(list(nx.selfloop_edges(G)))

nx.set_node_attributes(G, dict(G.degree(weight="weight")), "strength")

nx.set_node_attributes(G, Convert(list(np.stack(node_sizes))), "size")

nx.set_node_attributes(G, colors, "color")

G = nx.relabel_nodes(G, dict(zip(range(len(nodes)), list(nodes))))

circ = CircosPlot(
    G,
    node_labels=True,
    figsize=(10, 10),
    edge_color="weight",
    edge_width="weight",
    node_color="size",
    node_label_layout="rotation",
    fontsize=12,
    node_palette=colors,
    group_legend=False,
)
circ.draw()

circ.sm.colorbar.remove()

This is the piece of code I'm using to plot.

Thank you.