diff --git a/example.json b/example.json index 65e14b4..a13fbd7 100644 --- a/example.json +++ b/example.json @@ -1,7 +1,7 @@ { "members": [ {"name": "Alice", "color": "pink"}, {"name": "Bob", "color": "blue"}, - {"name": "Sam", "color": "green"}, + {"name": "Sam"}, {"name": "Eve", "color": "pink"}, {"name": "Charles", "color": "blue"}, {"name": "Max", "color": "yellow"} diff --git a/example.png b/example.png index e03a331..7d7082a 100644 Binary files a/example.png and b/example.png differ diff --git a/polygraph.py b/polygraph.py index 9b06400..7fe07c7 100755 --- a/polygraph.py +++ b/polygraph.py @@ -8,7 +8,7 @@ def parse_args(): 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('--output', '-o', default='network.png', help='Output image file. Format auto-detected from file extension') - parser.add_argument('--gender', '-g', action='store_true', help='Include gender colors in output graph') + parser.add_argument('--color', '-c', action='store_true', help='Include node colors in output graph') return parser.parse_args() @@ -28,11 +28,11 @@ def main(): # Add nodes to graph for user in data['members']: - gender_color = 'white' - if settings.gender: - gender_color = user['color'] + node_color = 'white' + if settings.color and user.has_key('color'): + node_color = user['color'] - graph.add_node(user['name'], fillcolor=gender_color) + graph.add_node(user['name'], fillcolor=node_color) # Add edges to graph edge_style = 'solid'