Skip to content

Instantly share code, notes, and snippets.

@swinton
Created November 3, 2011 12:32
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 swinton/1336383 to your computer and use it in GitHub Desktop.
Save swinton/1336383 to your computer and use it in GitHub Desktop.
# Klout scores
klouts <- read.csv("klout-scores.csv", header=TRUE)
# Radiuses for rendering bubbles
radius <- sqrt( klouts$klout_score / pi )
# Competitor matrix
competitors <- read.csv("competitors.csv", header=TRUE)
# Co-ords for plotting competitors
coords <- cmdscale(competitors, k=2)
# Plot the co-ordinates
plot(coords, type="n")
# Fill colours
fill_colours <- c()
for (i in 1:length(klouts$type)) {
if (klouts$type[i] == "us") {
fill_colours <- c(fill_colours, "#CBE11D")
}
else if (klouts$type[i] == "current") {
fill_colours <- c(fill_colours, "#2DB3CB")
}
else if (klouts$type[i] == "future") {
fill_colours <- c(fill_colours, "#BC006B")
}
}
# Show competitors
symbols(coords, circles=radius, inches=0.35, fg="white", bg=fill_colours, xlab="X", ylab="Y")
# Label competitors
text(coords, labels=names(competitors), cex=0.5, col="white")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment