Allow arbitrary usage of edge line styles
This commit is contained in:
parent
dd461e3ec0
commit
bd35cc174e
25
polygraph.py
25
polygraph.py
|
@ -5,14 +5,6 @@ import json
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
# These are the attributes to use for color-coding the graphs
|
# These are the attributes to use for color-coding the graphs
|
||||||
# fixme: make these configurable
|
|
||||||
|
|
||||||
|
|
||||||
# Relationship types... feel free to edit to suit your poly family's needs
|
|
||||||
relationship_colors = {
|
|
||||||
'stable': 'blue',
|
|
||||||
'developing': 'red'
|
|
||||||
}
|
|
||||||
|
|
||||||
# Three gender colours, so that we encapsulate masculine, feminine, and a catch-all for other identities
|
# Three gender colours, so that we encapsulate masculine, feminine, and a catch-all for other identities
|
||||||
# If you'd rather explicitly colour-code other identities, just add them :)
|
# If you'd rather explicitly colour-code other identities, just add them :)
|
||||||
|
@ -22,12 +14,6 @@ gender_colors = {
|
||||||
'o': 'green',
|
'o': 'green',
|
||||||
}
|
}
|
||||||
|
|
||||||
# This represents whether a particular relationship involves any
|
|
||||||
# std risk. The values are applied to the edge 'style' attribute.
|
|
||||||
sti_styles = { 'yes': 'solid',
|
|
||||||
'no': 'dashed',
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
parser = argparse.ArgumentParser(description='Generate graphs of polyamorous family networks from data files')
|
parser = argparse.ArgumentParser(description='Generate graphs of polyamorous family networks from data files')
|
||||||
|
@ -62,15 +48,14 @@ def main():
|
||||||
graph.add_node(user['name'], fillcolor=gender_color)
|
graph.add_node(user['name'], fillcolor=gender_color)
|
||||||
|
|
||||||
# Add edges to graph
|
# Add edges to graph
|
||||||
sti_style = 'solid'
|
edge_style = 'solid'
|
||||||
relationship_color = 'black'
|
|
||||||
|
|
||||||
for (member1,member2,rel,sti) in data['relationships']:
|
for (member1,member2,rel,edge) in data['relationships']:
|
||||||
if settings.relationship_types:
|
if settings.relationships:
|
||||||
sti_style = sti_styles[sti]
|
edge_style = edge
|
||||||
relationship_color = relationship_colors[rel]
|
relationship_color = relationship_colors[rel]
|
||||||
|
|
||||||
graph.add_edge(member1, member2, style=sti_style, color=relationship_color)
|
graph.add_edge(member1, member2, style=edge_style, color='black')
|
||||||
|
|
||||||
graph.layout()
|
graph.layout()
|
||||||
graph.draw(settings.output)
|
graph.draw(settings.output)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user