-1

I'm trying to make a pie chart that's representing the amount of pollution from a given year from different industry sectors. This is from a public EPA dataset. Since there are many industry sectors, I don't want to include all of them, and want to include a lump "other" category. However, I don't want this category showing up in the middle of the chart, even though it is larger than some of the smaller slivers. I'd rather it be at the end. Any idea how to fix? Thanks.

group_by(tri1987tce, IndSec) %>% 
  summarize(amt=sum(`61. ON-SITE RELEASE TOTAL`)/1000) %>%
  ggplot(aes(x="", y=amt, fill=reorder(IndSec, amt))) +
  geom_bar(stat = "identity", width =1, color="white") +
  coord_polar("y", start=0) + theme_void()

enter image description here

Quinten
  • 35,235
  • 5
  • 20
  • 53
nahgemp
  • 1
  • 1
  • Welcome to SO! It would be easier to help you if you provide [a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including a snippet of your data or some fake data. – stefan Jul 12 '22 at 20:12
  • Maybe this is what you need https://stackoverflow.com/questions/47752037/pie-chart-with-ggplot2-with-specific-order-and-percentage-annotations – Isaac Jul 12 '22 at 20:18

1 Answers1

1

You can use forcats::fct_relevel to move a factor level to the last position.

fill = forcats::fct_relevel(reorder(IndSec, amt), "Other", after = Inf)
Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294