Skip to content

Instantly share code, notes, and snippets.

@diffalot
Forked from chrisgemignani/gist:47013
Created January 6, 2010 08:51
Show Gist options
  • Save diffalot/270148 to your computer and use it in GitHub Desktop.
Save diffalot/270148 to your computer and use it in GitHub Desktop.
size(520, 620)
from math import pi
data = [i
#User,"Feminism","History of Feminism","Women's Suffrage","Women's Rights","Radical Feminism","Ecofeminism","Men's Rights","Antifeminism","Sex-Positive Feminism","Men and Feminism","Liberal Feminism","Cultural Feminism","Anarcha-Feminism","Feminist Theology","Marxist Feminism"],
["Cailil",701,91,22,60,10,14,35,0,0,18,3,16,2,0,1],
["Catamorphism",120,0,0,0,10,0,0,15,28,0,0,0,0,0,0],
["SmackBot (bot)",32,13,10,7,15,2,18,12,6,10,4,3,2,3,2],
["Dysprosia",97,2,0,0,6,0,9,0,0,0,1,0,0,0,0],
["Binksternet",27,6,60,0,4,0,0,0,0,0,0,0,0,2,0],
["Bremskraft",68,0,0,0,0,4,7,0,0,0,20,0,0,0,0],
["ClueBot (bot)",43,2,32,6,2,0,4,3,2,0,0,0,0,1,0],
["JCDenton2052",19,20,0,5,9,4,0,6,3,14,5,5,0,1,2],
["VoluntarySlave",14,8,0,7,14,0,0,23,4,0,1,3,2,0,3],
["Owen",0,0,0,0,2,43,0,3,1,0,1,1,14,0,2],
["AntiVandalBot",16,0,0,15,0,1,0,3,0,0,0,0,0,0,1],
["AnnaAniston",17,0,0,0,7,0,0,0,3,0,0,0,7,0,0],
["Sardanaphalus",0,3,0,0,2,3,0,0,2,2,2,2,2,4,2],
["Taranet",0,3,0,0,0,0,0,0,0,0,1,0,0,18,1],
["VoABot II",11,0,8,0,2,0,0,2,0,0,0,0,0,0,0],
["Rjwilmsi",10,6,0,0,0,0,0,0,0,3,1,0,0,0,0],
["Blackcats",10,0,0,0,2,2,0,0,3,0,0,0,0,0,0],
["Dakinijones",0,0,0,0,2,5,0,0,2,1,1,1,1,0,1],
["Cerberus of elyssia",0,0,0,0,2,0,0,0,0,0,1,1,1,0,1],
["Cantaire87",0,0,0,0,0,0,0,0,0,0,1,2,1,0,1],
["YurikBot (bot)",0,0,0,0,0,2,0,0,0,0,1,1,0,0,1],
]
colormode(HSB)
# hue sat brt alpha
grey = color(0.0, 0.0, 0.3, 0.5)
highlight = color(0.6, 0.5, 1.0, 0.8)
black = color(0,0, 0.3, 0.9, 1.0)
# constants
LABELWIDTH = 150 # width of row label
COLWIDTH = 75 # width of columns
LINEWIDTH = 470 # width of line to draw under each row
ROWHEIGHT = 22 # height of each row
MINLABEL = 0.2 # minimum size of circle for drawing a label
LABELSIZE = 10 # font size of labels on circles
CIRCLESCALE = 4000 # scale the size of the circles
font("Helvetica Neue")
fontsize(12)
fill(black)
translate(0,30)
align(CENTER)
text("Expedia", LABELWIDTH-50, 0, width=100)
text("Travelocity", LABELWIDTH+1*COLWIDTH-50, -15, width=100)
text("Hotel-Guides", LABELWIDTH+2*COLWIDTH-50, 0, width=100)
text("Yahoo! Travel", LABELWIDTH+3*COLWIDTH-50, -15, width=100)
text("TripAdvisor", LABELWIDTH+4*COLWIDTH-50, 0, width=100)
translate(0,30)
font("Helvetica Neue Light")
for row in data:
rowlabel, rowdata = row[0], row[1:]
rowmax = max(rowdata)
fill(black)
align(LEFT)
fontsize(12)
text(rowlabel, 10, 0, width=LABELWIDTH)
# draw a light grey line below each row
stroke(1.0, 0.0, 0.55)
strokewidth(0.2)
line(0, 5, LINEWIDTH, 5)
# save the current origin
push()
translate(LABELWIDTH, -6)
for column_num, val in enumerate(rowdata):
if val > 0.0:
r = (CIRCLESCALE*val / pi)**0.5
# draw the shape
fill(grey)
if val == rowmax:
fill(highlight)
oval(-r/2,-r/2, r, r)
if val > MINLABEL:
fontsize(LABELSIZE)
fill(black)
text("%.1f%%" % (100*val),4-r/2,0,width=COLWIDTH)
# move over a row
translate(COLWIDTH, 0)
# restore the origin
pop()
# move down a row
translate(0, ROWHEIGHT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment