Home > Mobile >  Can not add number to pie chart for the slices only a pie chart come without number
Can not add number to pie chart for the slices only a pie chart come without number

Time:04-15

I want a create a pie chart below. But I can add the percentage number to the slices. Below is my code. Thanks for helping.

slices <- c(51,49)
cs <- c("male", "female")
pie(slices, labels = cs, col=c("blue", "red"), main="Female male ration at Harvard")

CodePudding user response:

You could do

slices <- c(51,49)
cs <- c("male", "female")
pie(slices, labels = paste0(cs, ' ', slices, '%'),  
    col=c("blue", "red"), main="Female male ratio at Harvard")

enter image description here

  •  Tags:  
  • r
  • Related