Home > Blockchain >  How to rid of some decimals on my pie chart in R
How to rid of some decimals on my pie chart in R

Time:05-20

I've been looking all day for this answer, but with any luck. I'm newbie and I've been trying to do a Pie chart with ggplot2, but I can't reduce decimals on my pie chart and put everything in order.

ggplot(data=wolf_summary, mapping = aes(x= "", y = Percent, fill= Hobby))  
      geom_bar(width = 1, stat = "identity")   
      scale_y_continuous(breaks = round(cumsum(rev(wolf_summary$Percent)), 1))  
      coord_polar("y", start = 0, direction = -1)   
      labs(title= "Wolf Villagers Hobbies")  
      geom_text(aes(label = Percent),
        position = position_stack(vjust = 0.5))

This is my pie chart: https://i.imgur.com/upWTuFQ.png

I wonder if anyone can help me. tysm in advance!

CodePudding user response:

You can use round function in the label.

  geom_text(aes(label = round(Percent, digits = 1),
           position = position_stack(vjust = 0.5))
  •  Tags:  
  • r
  • Related