jeudi 14 octobre 2021

Is there a function to add patterns to a ggplot pie chart whilst keeping colours?

I'm looking to create a pie chart with the relative abundance of groups, however, groups are then split into sub groups e.g. Group 1 is split into group 1a, group 1b, group 1c and so one for group 2 ect. I have 30 groups with varying levels of subgroups within e.g. some groups have just 2 subgroups and some have 4.

I would like to colour the slices of a pie for a group the same colour but the subgroups as different patterns. e.g. Group one would all have a base colour of red, but group 1a would be solid colour, group 1b would be red with stripes and group 1c would be red with dots.

Just wondered if anyone could inform me of the best way get a pie chart with colours in addition to patterns. Any material I have found thus far is just for putting different patterns on as a fill rather than manipulating the colours e.g. ggpattern.

Your help is much appreciated! Please find my code for my pie chart below.

bpwc<- ggplot(data, aes(x="", y=rel_abund, fill=Order_group))+
  geom_bar(width = 1, stat = "identity", color="black")

piewc <- bpwc + coord_polar("y", start=0)
piewc +theme_void()+facet_wrap(depth~replicate)+scale_fill_manual(values =c(glasbey()))```





Aucun commentaire:

Enregistrer un commentaire