Created
September 7, 2019 17:02
-
-
Save julian-west/29299749dd7591563e67ddef962ac355 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def assign_colour(correlation): | |
if correlation <= 0: | |
return "#ffa09b" # red | |
else: | |
return "#9eccb7" # green | |
def assign_thickness(correlation, benchmark_thickness=2, scaling_factor=3): | |
return benchmark_thickness * abs(correlation)**scaling_factor | |
def assign_node_size(degree, scaling_factor=50): | |
return degree * scaling_factor | |
# assign colours to edges depending on positive or negative correlation | |
# assign edge thickness depending on magnitude of correlation | |
edge_colours = [] | |
edge_width = [] | |
for key, value in nx.get_edge_attributes(Gx, 'correlation').items(): | |
edge_colours.append(assign_colour(value)) | |
edge_width.append(assign_thickness(value)) | |
# assign node size depending on number of connections (degree) | |
node_size = [] | |
for key, value in dict(Gx.degree).items(): | |
node_size.append(assign_node_size(value)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment