Search code examples
rpie-chart

I would like to color my pie but the #numbers doesn't work. What am I doing wrong?


I would like to color my pie but the #numbers doesn't work. What am I doing wrong? The code gives the pie but with other colors. I am using the package "Palmerpenguins" in R.

slices <- c (146,119,68)
lbls <- c ("Adelie 146", "Gentoo 119", "Chinstrap 68")
clrs <- c ("#527f85", "#f08fff", "#7d9cf6")

pie(slices, labels= lbls, main= "Aantallen Pinguins per soort", clockwise = TRUE)

Solution

  • Include col = clrs :

    slices <- c (146,119,68)
    lbls <- c ("Adelie 146", "Gentoo 119", "Chinstrap 68")
    clrs <- c ("#527f85", "#f08fff", "#7d9cf6")
    
    pie(slices, labels= lbls, main= "Aantallen Pinguins per soort", 
        clockwise = TRUE, col = clrs)
    

    enter image description here