-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
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
Backfill labeled node with color #30
Comments
What do you mean by backfill? |
I mean background color. However that doesn't seem to be possible. import networkx as nx
import matplotlib.pyplot as plt
import random
from grave import plot_network
graph = nx.barbell_graph(10, 14)
nx.set_node_attributes(graph, dict(graph.degree()), 'degree')
graph = nx.relabel_nodes(graph, {k: str(i) for i, k in enumerate(graph.node)})
def degree_colorer(node_attributes):
deg = node_attributes['degree']
shape = random.choice(['s', 'o', '^', 'v', '8'])
if deg > 5:
return {'color': 'r', 'size': 20*deg,
# 'shape': shape,
'label': 'hi'
}
return {'color': 'b', 'size': 20*deg,
# 'shape': shape,
'label': 'hi'
}
def pathological_edge_style(edge_attrs):
return {'color': random.choice(['r', (0, 1, 0, .5), 'xkcd:ocean'])}
fig, ax = plt.subplots()
plot_network(graph, ax=ax,
node_style=dict(node_size=20, color='r', edgecolor='r'),
# node_style=degree_colorer,
edge_style=pathological_edge_style,
node_label_style={'font_size': 20,
'font_color': 'r',
'backgroundcolor': 'b'
}
)
plt.show()
'''
We can calculate the execution order by walking the graph from a node and
summing it's edge labels (with zeros if there is none). This way all the nodes
on the first path will have a value of zero. Finally, since some nodes are
part of multiple trr
''' Is the |
You are correct -- while that property (and others) are available in matplotlib, the GraVE code doesn't pass through many text attributes to the label artists. Is there a reason we limit the attributes using |
FYI I also hacked the |
Ahh -- in your example, the text is so large that it covers up the nodes. You have set the node_size to 20 but that doesn't seem to do anything. A little hunting shows t hat you need to set size=20 for nodes rather than node_size . Looks like we have to make styles better at catching buggy input! Anyway, if you use |
Yey human fuzzing! |
Is it possible to backfill a labeled node with a color? If so, how?
The text was updated successfully, but these errors were encountered: