Skip to content

Instantly share code, notes, and snippets.

@revodavid
Created June 14, 2019 00:25
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 revodavid/00b9c1d1100d04210623f88edbdbc79a to your computer and use it in GitHub Desktop.
Save revodavid/00b9c1d1100d04210623f88edbdbc79a to your computer and use it in GitHub Desktop.
## get n colors with locations
random.points <- function(n,width=100,height=100) {
hexbot <- GET(endpoint, query=list(count=n, width=width, height=height))
data <- matrix(unlist(content(hexbot)$colors),ncol=3,byrow=TRUE)
cols <- data[,1]
x <- as.numeric(data[,2])
y <- as.numeric(data[,3])
data.frame(cols, x, y)
}
with(random.points(25,100,100),
plot(x,y,col=cols,xlim=c(0,100), ylim=c(0,100)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment