I'm using geom_textpath
to add labels to a double donut chart but the labels are not aligned to the middle.
How can I align the labels in the middle or the center of each segment?
library(magrittr)
library(ggplot2)
library(geomtextpath)
pie_data <- data.frame(category=c('A','B','C','A','B','C'),
year=c(2020,2020,2020,2021,2021,2021),
sales=c(40,30,20,10,15,10))
pie_data %>% ggplot(aes(x=year,y=sales,fill=category))+
geom_col(position='fill',width=1,color='white')+
lims(x=c(2018,2023))+
geom_textpath(position='fill',angle=90,hjust=2,alpha=1,
aes(color=factor(year),
label=paste0(category,':',sales)))+
coord_polar(theta = 'y')+
theme_void()