Add options to control coloring of gender and relationship types. Change fluid exchange language to be framed in terms of STI risk
This commit is contained in:
parent
cb7abf01a6
commit
49f6130838
41
polygraph.py
41
polygraph.py
|
@ -7,11 +7,12 @@ 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
|
# fixme: make these configurable
|
||||||
|
|
||||||
# This represents whether a particular relationship involves the
|
|
||||||
# *risk* of fluid exchange. The values are applied to the edge 'style' attribute
|
# Relationship types... feel free to edit to suit your poly family's needs
|
||||||
fluid_colors = { 'yes': 'solid',
|
relationship_colors = {
|
||||||
'no': 'dashed',
|
'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 :)
|
||||||
|
@ -21,17 +22,19 @@ gender_colors = {
|
||||||
'o': 'green',
|
'o': 'green',
|
||||||
}
|
}
|
||||||
|
|
||||||
# Relationship types... feel free to edit to suit your poly family's needs
|
# This represents whether a particular relationship involves any
|
||||||
relationship_colors = {
|
# std risk. The values are applied to the edge 'style' attribute.
|
||||||
'stable': 'blue',
|
sti_styles = { 'yes': 'solid',
|
||||||
'developing': 'red'
|
'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')
|
||||||
parser.add_argument('--input', '-i', default='network.json', help='Input file in json format')
|
parser.add_argument('--input', '-i', default='network.json', help='Input file in json format')
|
||||||
parser.add_argument('--output', '-o', default='network.png', help='Output image file. Format auto-detected from file extension')
|
parser.add_argument('--output', '-o', default='network.png', help='Output image file. Format auto-detected from file extension')
|
||||||
|
parser.add_argument('--gender', '-g', action='store_true', help='Enable gender in output graph')
|
||||||
|
parser.add_argument('--relationship-types', '-rt', action='store_true', help='Enable relationship details (std risk, relationship type) in output graph')
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,12 +53,24 @@ def main():
|
||||||
graph.edge_attr['arrowsize'] = 0.5
|
graph.edge_attr['arrowsize'] = 0.5
|
||||||
|
|
||||||
# Add nodes to graph
|
# Add nodes to graph
|
||||||
|
gender_color = 'white'
|
||||||
|
|
||||||
for user in data['members']:
|
for user in data['members']:
|
||||||
graph.add_node(user['name'], fillcolor=gender_colors[user['gender']])
|
if settings.gender:
|
||||||
|
gender_color = gender_colors[user['gender']]
|
||||||
|
|
||||||
|
graph.add_node(user['name'], fillcolor=gender_color)
|
||||||
|
|
||||||
# Add edges to graph
|
# Add edges to graph
|
||||||
for (member1,member2,rel,fluid) in data['relationships']:
|
sti_style = 'solid'
|
||||||
graph.add_edge(member1, member2, style=fluid_colors[fluid], color=relationship_colors[rel])
|
relationship_color = 'black'
|
||||||
|
|
||||||
|
for (member1,member2,rel,sti) in data['relationships']:
|
||||||
|
if settings.relationship_types:
|
||||||
|
sti_style = sti_styles[sti]
|
||||||
|
relationship_color = relationship_colors[rel]
|
||||||
|
|
||||||
|
graph.add_edge(member1, member2, style=sti_style, color=relationship_color)
|
||||||
|
|
||||||
graph.layout()
|
graph.layout()
|
||||||
graph.draw(settings.output)
|
graph.draw(settings.output)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user