pie <- function (x,center=c(0,0), labels = names(x), edges = 200, radius = 0.8, clockwise = FALSE, init.angle = if (clockwise) 90 else 0, density = NULL, angle = 45, col = NULL, border = NULL, lty = NULL, main = NULL, ...) { if (!is.numeric(x) || any(is.na(x) | x < 0)) stop("'x' values must be positive.") if (is.null(labels)) labels <- as.character(1:length(x)) x <- c(0, cumsum(x)/sum(x)) dx <- diff(x) nx <- length(dx) pin <- par("pin") usr <- par("usr") rhoy <- (usr[4]-usr[3])/(usr[2]-usr[1])*pin[1]/pin[2] rhox <- 1 if(rhoy>1) { rhox <- 1/rhoy rhoy <- 1 } if (is.null(col)) col <- if (is.null(density)) c("white", "lightblue", "mistyrose", "lightcyan", "lavender", "cornsilk") else par("fg") col <- rep(col, length.out = nx) border <- rep(border, length.out = nx) lty <- rep(lty, length.out = nx) angle <- rep(angle, length.out = nx) density <- rep(density, length.out = nx) twopi <- if (clockwise) -2 * pi else 2 * pi t2xy <- function(t) { t2p <- twopi * t + init.angle * pi/180 list(x = radius * cos(t2p), y = radius * sin(t2p)) } for (i in 1:nx) { n <- max(2, floor(edges * dx[i])) P <- t2xy(seq(x[i], x[i + 1], length = n)) P$y <- P$y*rhoy P$x <- P$x*rhox polygon(c(P$x, 0)+center[1], c(P$y, 0)+center[2], density = density[i], angle = angle[i],border = border[i], col = col[i], lty = lty[i]) P <- t2xy(mean(x[i + 0:1])) P$y <- P$y*rhoy P$x <- P$x*rhox if (!is.na(lab <- labels[i]) && lab != "") { lines(c(1,1.05)*P$x+center[1], c(1,1.05)*P$y+center[2]) text(1.1 * P$x + center[1], 1.1 * P$y + center[2], lab, cex=2, xpd = TRUE, adj = ifelse(P$x <0, 1, 0), ...) } } invisible(NULL) } options(digits=17) options(warn=-1) png("pie.png",height=480, width=640,res=72) plot(c(-1.43,1.43),c(-1.21,1.21),type="n",main="pres",xlab="",ylab="",axes=FALSE, panel.first=grid(col="gray"), cex.main=2, cex.axis=1.5, cex.lab=1.5) dataOT <- matrix(c(5665855,4804713,4610113,1949170,1630045,1518528,1495724,1210562,1204689,1113484,3295588), nrow=11, ncol=1) pie(dataOT[,1],center=c(0,0),radius=1,labels=c("chirac","lepen","jospin","bayrou","laguiller","chevenement","mamere","besancenot","saint-josse","madelin","cumul candidats < 3.5% "),col=c("blue","white","pink","yellow","red","ivory","green","orange","maroon","violet","purple")) dev.off()