[R] specifying colours in a ggplot2 piechart
baptiste auguie
baptiste.auguie at googlemail.com
Tue Nov 23 20:02:49 CET 2010
fixing the various typos in your code, this works,
lat_plot() +
scale_fill_manual(value=mycolours)
HTH,
baptiste
On 23 November 2010 19:47, John Kane <jrkrideau at yahoo.ca> wrote:
> Someone was asking how to do a 16 category piechart in OpenOffice Calc and it appears that it can not be done (which we, probably, should be happy about) but I thought that I'd try it in ggplot2.
>
> It works but I then thought I'd like to make the colours more distinctive but fro some reason I don't seem to be able to use manually assigned colours.
>
> Can anyone suggest where I'm going wrong?
>
> Thanks
>
> ===================================================================
>
>
> library(ggplot2)
> mypie <- data.frame(xx = c(12,13,6,7,9,10,4, 3, 8, 6, 8, 4, 6,5,2,3),
> zz = letters[1:16])
>
> mycolours <- c(a = "red", b = "blue", c = "green", d = "orange", e = "red",
> f = "blue", g = "geen", h = "orange", i = "red", j = "blue",
> k = "green", l = "orange", m = "red", n = "blue", o = "green",
> p = "orange" )
>
> pie1 <- ggplot(mypie, aes(x = factor(zz), fill = factor(zz))) + geom_bar(width = 1)
> pie2 <- pie + coord_polar(theta = "x") + scale_colour_brewer(Pastel1)
> pie2
>
> # try to get even nastier piechart with ugly colours to provide rast.
>
> pie3 <- pie2 + scale_colour_manual(value=mycolours)
> pie
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list