I use the following code to create a schedule of parliamentary seats with R for the 2013 election results in Germany.
I would like to change the colors for each side (CDU / CSU β red, SPD β blue, Linke β yellow and Gruene β green). When I try to do this, the colors seem random, destroying the sequence of sides in the graph.
I also want to remove the black outline of the graph in order to display only the graph of places.
VoteGermany2013 <- data.frame(Party=c( "CDU/CSU", "SPD", "LINKE","GRUENE"), Result=c(311,193,64,63)) seats <- function(N,M, r0=2.5){ radii <- seq(r0, 1, len=M) counts <- numeric(M) pts = do.call(rbind, lapply(1:M, function(i){ counts[i] <<- round(N*radii[i]/sum(radii[i:M])) theta <- seq(0, pi, len = counts[i]) N <<- N - counts[i] data.frame(x=radii[i]*cos(theta), y=radii[i]*sin(theta), r=i, theta=theta) } ) ) pts = pts[order(-pts$theta,-pts$r),] pts } election <- function(seats, counts){ stopifnot(sum(counts)==nrow(seats)) seats$party = rep(1:length(counts),counts) seats } layout = seats(631,16) result = election(layout, VoteGermany2013$Result)

source share