I'd like to create a plot similar to this, where each point represents a unique data point of a specific type (eg. red group or blue group), and the points of each group form a circular shape.
I have so far gotten this far, using the packcircles function in R:
How do I "group" the different colours together? Since I am using the packcircle function, the circle is drawn from the center and then spirals outward, so ordering the points does group them, but I'd rather something more similar to the example I provided above.
Here is the code I used to generate the plot
library(packcircles)
library(ggplot2)
library(plyr)
library(dplyr)
Sample data
data <- data.frame(group=paste("Group", letters[1:4]), value=rep(1,100))
data <- data[order(data$group), ]
Generate layout using packcircles function in R
packing <- circleProgressiveLayout(data$value, sizetype = "area")
id <- data$group
packing <- cbind(id,packing)
dat.gg <- circleLayoutVertices(packing, idcol=1, xysizecols=2:4, npoints=1)
Make the plot using ggplot2
ggplot() +
geom_point(data = dat.gg, aes(x,y, colour=factor(id))) +
theme_minimal() +
theme(legend.position="none",
panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),
axis.text=element_blank())
Thanks in advance.