DONUT CHART
I personally don’t like pie charts that much, I prefer donut charts, they take up less space and the center can be used for extra annotations. In ggplot2 to get the “Donut” you design a bar chart (geom_bar) and then just bend it (coord_polar) at the extremities to get a donut.
To reproduce the chart below, you can download the data from the RLadies Tbilisi github webpage, Session 9 on Plotting.
Alternatively here’s the dput(-ted) data:
structure(list(X = 1:3, variable = structure(c(1L, 1L, 1L), .Label = "Export of Services", class = "factor"), type = structure(c(3L, 2L, 1L), .Label = c("Remaining", "Transportation", "Travel"), class = "factor"), year = c(2012L, 2012L, 2012L ), value = c(55.5, 33.4, 11.1), geo = c(NA, NA, NA), pos = c(27.75, 72.2, 94.45)), .Names = c("X", "variable", "type", "year", "value", "geo", "pos"), class = "data.frame", row.names = c(NA, -3L))
Exports of services by EBOPS category
#set the working directory setwd("/Users/DrVenkman/The Gatekeepers Folder/") require(tidyverse) #data manipulation exp.ser % filter(variable == "Export of Services") exp.ser % group_by(year) %>% mutate(pos = cumsum(value)- value/2) p <- ggplot(exp.ser, aes(x=2, y=value, fill=type))+ geom_bar(stat="identity")+ geom_text( aes(label = value, y=pos), size=10, fontface="bold")+ xlim(0.5, 2.5) + coord_polar(theta = "y")+ labs(x=NULL, y=NULL)+ labs(fill="") + scale_fill_manual(values = c(Remaining = "blue", Transportation = "#E69F00", Travel= "#D55E00"), name="")+ ggtitle("Exports of services by EBOPS category, 2013")+ theme_bw()+ theme(plot.title = element_text(face="bold",family=c("sans"),size=15), legend.text=element_text(size=10), axis.ticks=element_blank(), axis.text=element_blank(), axis.title=element_blank(), panel.grid=element_blank(), panel.border=element_blank()) p