Last active
September 7, 2019 13:54
-
-
Save VictorSaenger/2821817aab361d81a3ea4360b65e0ab3 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
| #to plot quotes heatmap: | |
| plt.figure(figsize=(18, 16)) | |
| sns.heatmap(data=sM_All,annot=False,linewidths=0.1, cmap="YlGnBu") | |
| plt.show() | |
| #to render graph: | |
| #Import array to netowrkx object with a given threshold: | |
| G = nx.from_numpy_array(sM_All>0.25) | |
| #figure layout and size: | |
| pos = nx.kamada_kawai_layout(G) | |
| plt.figure(figsize=(10, 10)) | |
| plt.axis('off') | |
| #node size input should be changed according to network size: | |
| nx.draw_networkx_nodes(G, pos, node_size=100, \ | |
| #this simple trick allows to render the graph with colors according to classes: | |
| cmap=plt.cm.Dark2, node_color = list(classes)) | |
| nx.draw_networkx_edges(G, pos, alpha=0.15, width=0.2) | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment