I was asked to recreate the following style of plot. (Please ignore the question of whether this is a good type of visualization and charitably consider this as adding a colorf
Here's a non-ggplot2 (base R graphics) solution using the plotrix
package, which contains two nice functions: draw.circle()
and draw.arc()
:
circBarPlot <- function(x, labels, colors=rainbow(length(x)), cex.lab=1) {
require(plotrix)
plot(0,xlim=c(-1.1,1.1),ylim=c(-1.1,1.1),type="n",axes=F, xlab=NA, ylab=NA)
radii <- seq(1, 0.3, length.out=length(x))
draw.circle(0,0,radii,border="lightgrey")
angles <- (1/4 - x)*2*pi
draw.arc(0, 0, radii, angles, pi/2, col=colors, lwd=130/length(x), lend=2, n=100)
ymult <- (par("usr")[4]-par("usr")[3])/(par("usr")[2]-par("usr")[1])*par("pin")[1]/par("pin")[2]
text(x=-0.02, y=radii*ymult, labels=paste(labels," - ", x*100, "%", sep=""), pos=2, cex=cex.lab)
}
circBarPlot(Percent/100, Category)
text(0,0,"GLOBAL",cex=1.5,col="grey")
It gives me: