In [6]:
import matplotlib
%matplotlib inline
In [7]:
import pandas as pd
import networkx as nx
import matplotlib.pyplot as plt
In [8]:
petitions = pd.read_csv('/Users/catherinedumas/data/dissertaion/petitions/adjacency_matrix_10_percent_confidence.csv')
adjacency_matrix = petitions.T.values[1:]
petition_ids = petitions['Unnamed: 0']
petition_labels = {i:x for i,x in petition_ids.iteritems()}
In [9]:
print petition_ids
In [10]:
print petition_labels
In [11]:
print adjacency_matrix
In [12]:
graph = nx.from_numpy_matrix(adjacency_matrix)
In [13]:
categories_colors = pd.read_csv('../data/petitions_groups_colors.csv')
In [14]:
color_table = [ [row[0],row[1],row[2]] for i,row in categories_colors.iterrows()]
In [15]:
petitions_categories_table = pd.read_csv('../data/petitions_grouping.csv')
petitions_categories = { row[0]:row[1] for i,row in petitions_categories_table.iterrows() }
In [16]:
node_colors_array = [ color_table[petitions_categories[pid]] for pid in petition_ids ]
In [18]:
nx.draw_spring(graph, labels = petition_labels,node_color = node_colors_array)