I have made a circle pack with 3 fields i.e Acc type, Key and count of those of the key however I have another field of which I would like to colour them by. Is there a way I can colour the circles by the filter (there are 4 possible options for the filter)?
Acc type, Key, Current count
Acc Req, A, 2
Bench, Bench, 8
Int, In, 2
Int, B, 3
Acc Req, C, 4
Code:
install.packages("readxl")
library(readxl)
library(packcircles)
library(ggplot2)
library(dplyr)
library(reshape2)
library(viridisLite)
#Import 'BubblechartV3.0'
excel_sheets("BubblechartV3.0.xlsx")
Graph<-read_excel("BubblechartV3.0.xlsx",
sheet = "Graph")
pck <- circleProgressiveLayout(Graph$`Current Count`, sizetype= 'area')
head(pck)
# Two data sets needed to run code
mydata <- cbind(Graph, pck)
head(mydata)
myPlotCord <- circleLayoutVertices(pck)
head(myPlotCord)
pl <- ggplot() +
geom_polygon(data = myPlotCord, aes(x, y, group = id, fill= as.factor(id)), colour = "black", alpha = 0.6)+
geom_text(data = mydata, aes(x, y, size= `Current Count`, label = `Key`)) +
scale_size_continuous(range = c(1,4)) +
theme_void() +
theme(legend.position="none") +
coord_equal()
pl
I haven't found an option for this other than heirarchy circle packing was just hoping there'd be an easier way of grouping/colouring without that.
Edit: There are 3 columns i'm interested in: Acc type (this will be what i'd like to colour by (4 options)) Key - these are the individual bubbles in the circle packing Count - this defines how big the bubbles should be