Created
November 3, 2011 12:32
-
-
Save swinton/1336383 to your computer and use it in GitHub Desktop.
This file contains 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
# 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