Skip to content

Instantly share code, notes, and snippets.

@julian-west
Created September 7, 2019 17:05
Show Gist options
  • Save julian-west/3ce28ae7db651b2bb8fc9cd33b4f8d4d to your computer and use it in GitHub Desktop.
Save julian-west/3ce28ae7db651b2bb8fc9cd33b4f8d4d to your computer and use it in GitHub Desktop.
#create minimum spanning tree layout from Gx (after small correlations have been removed)
mst = nx.minimum_spanning_tree(Gx)
edge_colours = []
#assign edge colours
for key, value in nx.get_edge_attributes(mst, 'correlation').items():
edge_colours.append(assign_colour(value))
#draw minimum spanning tree. Set node size and width to constant
nx.draw(mst, with_labels=True, pos=nx.fruchterman_reingold_layout(mst),
node_size=200, node_color="#e1575c", edge_color=edge_colours,
width = 1.2)
#set title
plt.title("Asset price correlations - Minimum Spanning Tree",fontdict=font_dict)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment