Hi, I have used the following script to create a packed circle graph. But as you can see the legend isn't quite right. I have 9 'theme numbers' and I was the circles colour coded by 'theme number'. As you can see it is sort of managing it, but has multiple labels for each number
theme_number <- c(1, 2, 2, 3, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 5,
6, 7, 7, 8, 9)
themes <- c("Conditional support",
"Pull measures",
"A mix of push and pull measures",
"Safety",
"Air pollution",
"Health",
"Climate change",
"Traffic increase and displacement",
"Saving money",
"Fairness",
"Motives",
"Decision makers lack experience",
"Distrust",
"Engaging the public",
"A box ticking exercise",
"Status quo",
"BL won't work",
" Drivers should be prioritised",
"Space availability",
"Freedom"
)
totals <- c(7, 9, 5, 18, 12, 9, 9, 9, 7, 7, 8, 5, 16, 17, 11, 8, 7, 13, 9, 14)
data <- data.frame(theme_number = theme_number, Theme = themes, value = totals)
packing <- circleProgressiveLayout(data$value, sizetype='area')
data <- cbind(data, packing)
dat.gg <- circleLayoutVertices(packing, npoints=50)
ggplot() +
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=as.factor(id)), colour = NA, alpha = 0.6) +
geom_text(data = data, aes(x, y, size=value, label = str_wrap(Theme, width = 10))) +
scale_size_continuous(range = c(1,4)) +
# Specify colours based on theme number
scale_fill_manual(values = data$theme_number, labels = data$theme_number) +
labs(colour = data$theme_number) +
theme_void() +
theme(legend.position="left")+
coord_equal()
Created on 2024-05-13 with reprex v2.0.2