I want to add leading lines to all the slices
in my ggplot
Pie Chart
.
The second answer on this thread has them, but IDK what was added to reproduce the line, ggplot pie chart labeling
I've tried to copy and paste exactly what's in the line part of this answer, but I get some messed up lines: Controlling ticks and odd text in a pie chart generated from a factor variable in ggplot2
lossmixchart <- ggplot(currentLoss, aes(x="", y = currentLoss$Incurred, fill =
Branch)) +
geom_bar(width = 1, stat = "identity", colour = "black")+
coord_polar("y", start = 0) +
scale_fill_manual(values =
c("British Columbia" = "royalblue3", "Alberta" = "red",
"Saskatchewan" = "green4", "Manitoba" = "gold", "Ontario" =
"turquoise", "New Brunswick"= "purple", "PEI" = "hotpink",
"Nova Scotia" = "orange")) +
theme_void() +
ggtitle(paste0(
"Incurred Loss Mix in Thousands ", 2019, ": " , currentProvince)
) +
geom_text_repel(mapping = aes(label = paste0(Branch, " \n $",
prettyNum(round(currentLoss$Incurred/1000), big.mark = ",")), x = 2),
position = position_stack(vjust = 0.5), segment.size =.7, size = 5,
show.legend = FALSE) +
theme(legend.position = "none",
plot.title = element_text(face = "bold", size = 20),
axis.title = element_text(size=20),
axis.title.y = element_blank(),
axis.title.x = element_blank())
print(lossmixchart, floating = FALSE)
If I add nudge_x = .3
after size
, as some pages advise to try, I get this error:
Error: Specify either `position` or `nudge_x`/`nudge_y