Skip to main content


Showing posts from May, 2015

Static and moving circles

After the previous post on the packcircles package for R someone suggested it would be useful to be able to fix the position of selected circles. As a first attempt, I've added an optional weights argument to the circleLayout function. Weights can be in the range 0-1 inclusive, where a weight of 0 prevents a circle from moving, while a weight of 1 allows full movement. The updated code is at GitHub. Here's an example where the largest of a set of initially overlapping circles is fixed in place:

And here is the code for the example:
library(packcircles) library(ggplot2) library(gridExtra) # Generate some random overlapping circles ncircles <- 200 limits <- c(-50, 50) inset <- diff(limits) / 3 rmax <- 20 xyr <- data.frame( x = runif(ncircles, min(limits) + inset, max(limits) - inset), y = runif(ncircles, min(limits) + inset, max(limits) - inset), r = rbeta(ncircles, 1, 10) * rmax) # Index of the largest circle <- which(xyr$r == max(xyr$…