Skip to content

Instantly share code, notes, and snippets.

@sunlightlabs
Created May 5, 2009 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunlightlabs/107106 to your computer and use it in GitHub Desktop.
Save sunlightlabs/107106 to your computer and use it in GitHub Desktop.
Rep. Larry Kissell (D-NC),Rep. Sue Myrick (R-NC),0.511210762332
Rep. G.K. Butterfield (D-NC),Rep. Walter Jones (R-NC),0.543241843604
Rep. G.K. Butterfield (D-NC),Rep. Mike McIntyre (D-NC),0.911302584896
Rep. Patrick McHenry (R-NC),Rep. Brad Miller (D-NC),0.380952380952
Rep. Bob Etheridge (D-NC),Rep. Walter Jones (R-NC),0.575697211155
Rep. Howard Coble (R-NC),Rep. Mike McIntyre (D-NC),0.470734126984
Rep. Howard Coble (R-NC),Rep. Walter Jones (R-NC),0.800102511533
Rep. G.K. Butterfield (D-NC),Rep. Heath Shuler (D-NC),0.850261780105
Rep. Bob Etheridge (D-NC),Rep. Patrick McHenry (R-NC),0.393017456359
Rep. Bob Etheridge (D-NC),Rep. Heath Shuler (D-NC),0.875062468766
Rep. Howard Coble (R-NC),Rep. Heath Shuler (D-NC),0.507470376095
Rep. Mike McIntyre (D-NC),Rep. Brad Miller (D-NC),0.919245647969
Rep. Walter Jones (R-NC),Rep. Mike McIntyre (D-NC),0.625557206538
Rep. Walter Jones (R-NC),Rep. Mel Watt (D-NC),0.550623441397
Rep. Patrick McHenry (R-NC),Rep. Heath Shuler (D-NC),0.494069107788
Rep. David Price (D-NC),Rep. Mel Watt (D-NC),0.980966325037
Rep. Mike McIntyre (D-NC),Rep. Sue Myrick (R-NC),0.448328267477
Rep. Larry Kissell (D-NC),Rep. Mike McIntyre (D-NC),0.871681415929
Rep. Larry Kissell (D-NC),Rep. David Price (D-NC),0.946188340807
Rep. G.K. Butterfield (D-NC),Rep. Virginia Foxx (R-NC),0.352376137513
Rep. Brad Miller (D-NC),Rep. Mel Watt (D-NC),0.965450121655
Rep. Walter Jones (R-NC),Rep. David Price (D-NC),0.550826239359
Rep. Bob Etheridge (D-NC),Rep. Larry Kissell (D-NC),0.954545454545
Rep. Bob Etheridge (D-NC),Rep. Virginia Foxx (R-NC),0.381294964029
Rep. Howard Coble (R-NC),Rep. Patrick McHenry (R-NC),0.920716112532
Rep. Howard Coble (R-NC),Rep. Mel Watt (D-NC),0.393303348326
Rep. Sue Myrick (R-NC),Rep. David Price (D-NC),0.367669556349
Rep. G.K. Butterfield (D-NC),Rep. David Price (D-NC),0.97800511509
Rep. Virginia Foxx (R-NC),Rep. Sue Myrick (R-NC),0.92428066633
Rep. Brad Miller (D-NC),Rep. Sue Myrick (R-NC),0.386386898669
Rep. Bob Etheridge (D-NC),Rep. David Price (D-NC),0.970817120623
Rep. Howard Coble (R-NC),Rep. Brad Miller (D-NC),0.411205602801
Rep. Mike McIntyre (D-NC),Rep. David Price (D-NC),0.909530720851
Rep. Virginia Foxx (R-NC),Rep. David Price (D-NC),0.351181862036
Rep. Howard Coble (R-NC),Rep. Bob Etheridge (D-NC),0.420816733068
Rep. Virginia Foxx (R-NC),Rep. Brad Miller (D-NC),0.368370298939
Rep. Patrick McHenry (R-NC),Rep. David Price (D-NC),0.364824120603
Rep. Virginia Foxx (R-NC),Rep. Mel Watt (D-NC),0.35194992778
Rep. G.K. Butterfield (D-NC),Rep. Patrick McHenry (R-NC),0.364955935718
Rep. Larry Kissell (D-NC),Rep. Mel Watt (D-NC),0.945701357466
Rep. Larry Kissell (D-NC),Rep. Heath Shuler (D-NC),0.830188679245
Rep. Walter Jones (R-NC),Rep. Brad Miller (D-NC),0.564935064935
Rep. G.K. Butterfield (D-NC),Rep. Bob Etheridge (D-NC),0.964303926568
Rep. Virginia Foxx (R-NC),Rep. Mike McIntyre (D-NC),0.4375
Rep. G.K. Butterfield (D-NC),Rep. Mel Watt (D-NC),0.972448979592
Rep. Bob Etheridge (D-NC),Rep. Sue Myrick (R-NC),0.394803871625
Rep. Howard Coble (R-NC),Rep. Larry Kissell (D-NC),0.508849557522
Rep. G.K. Butterfield (D-NC),Rep. Howard Coble (R-NC),0.396750524109
Rep. Sue Myrick (R-NC),Rep. Heath Shuler (D-NC),0.494464944649
Rep. G.K. Butterfield (D-NC),Rep. Sue Myrick (R-NC),0.371856607812
Rep. Mike McIntyre (D-NC),Rep. Mel Watt (D-NC),0.901979719942
Rep. Heath Shuler (D-NC),Rep. Mel Watt (D-NC),0.847738693467
Rep. Brad Miller (D-NC),Rep. Heath Shuler (D-NC),0.860734037205
Rep. Virginia Foxx (R-NC),Rep. Walter Jones (R-NC),0.766913580247
Rep. Howard Coble (R-NC),Rep. Sue Myrick (R-NC),0.923640167364
Rep. Mike McIntyre (D-NC),Rep. Heath Shuler (D-NC),0.892981582877
Rep. Virginia Foxx (R-NC),Rep. Larry Kissell (D-NC),0.477876106195
Rep. Walter Jones (R-NC),Rep. Larry Kissell (D-NC),0.617117117117
Rep. Sue Myrick (R-NC),Rep. Mel Watt (D-NC),0.370143149284
Rep. Brad Miller (D-NC),Rep. David Price (D-NC),0.978973105134
Rep. Patrick McHenry (R-NC),Rep. Sue Myrick (R-NC),0.9428721174
Rep. Bob Etheridge (D-NC),Rep. Mel Watt (D-NC),0.958737864078
Rep. Virginia Foxx (R-NC),Rep. Heath Shuler (D-NC),0.482878411911
Rep. Walter Jones (R-NC),Rep. Heath Shuler (D-NC),0.646272493573
Rep. Walter Jones (R-NC),Rep. Sue Myrick (R-NC),0.780513357779
Rep. G.K. Butterfield (D-NC),Rep. Larry Kissell (D-NC),0.927884615385
Rep. Larry Kissell (D-NC),Rep. Brad Miller (D-NC),0.951327433628
Rep. Bob Etheridge (D-NC),Rep. Mike McIntyre (D-NC),0.933140933141
Rep. Bob Etheridge (D-NC),Rep. Brad Miller (D-NC),0.973748176957
Rep. Howard Coble (R-NC),Rep. David Price (D-NC),0.392481203008
Rep. Virginia Foxx (R-NC),Rep. Patrick McHenry (R-NC),0.938088162457
Rep. Walter Jones (R-NC),Rep. Patrick McHenry (R-NC),0.783468559838
Rep. G.K. Butterfield (D-NC),Rep. Brad Miller (D-NC),0.968861664114
Rep. Patrick McHenry (R-NC),Rep. Mike McIntyre (D-NC),0.452830188679
Rep. Patrick McHenry (R-NC),Rep. Mel Watt (D-NC),0.364182091046
Rep. Howard Coble (R-NC),Rep. Virginia Foxx (R-NC),0.900642609985
Rep. David Price (D-NC),Rep. Heath Shuler (D-NC),0.853915662651
Rep. Larry Kissell (D-NC),Rep. Patrick McHenry (R-NC),0.50892
from sunlightapi import sunlight
sunlight.apikey = 'sunlight9'
import csv
# create graph
graph = ximport("graph")
font("DejaVu Sans-Bold", 10)
g = graph.create(iterations=500, distance=3.0, layout='spring', depth=True)
# styles
s = g.styles.create("republican")
s.fill = color(1, 0, 0, 0.9)
s = g.styles.create("democrat")
s.fill = color(0, 0, 1, 0.9)
s = g.styles.create("current")
s.fill = color(1,1,1, 0.9)
# load data
pols = sunlight.legislators.getList(state='NC', title='Rep')
who = pols[random(0,9)]
diff = {}
for line in csv.reader(open('/home/james/ncreps.csv')):
if line[0] == str(who):
diff[line[1]] = float(line[2])
if line[1] == str(who):
diff[line[0]] = float(line[2])
min_score = min(diff.values())
max_score = max(diff.values())
for pol in pols:
g.add_node(str(pol), category=pol.party)
if pol != who:
print diff
g.add_edge( str(who), str(pol), (diff[str(pol)]-min_score)/max_score )
for n in g.nodes_by_category('R'):
n.style = 'republican'
for n in g.nodes_by_category('D'):
n.style = 'democrat'
g.solve()
g.draw(weighted=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment