'Can't draw a concentric pie chart in R

I have the following data:

Phyla       V4         Fl
 <chr>     <dbl>      <dbl>

Proteobacteria  88.58    81.43  
Firmicutes  7.33    15.34   
Actinobacteriota    1.55    1.94        
Bacteroidota    2.20    1.25    

I want to display the data using a concentric pie chart. I have a couple of trials:

mycols <- c("#eee0b1", "#da8a67", "#e63e62", "#0033aa")
ggplot(df, aes(x = 2, y = V4, fill = Phyla)) +
  geom_bar(stat = "identity", color = "white") +
  coord_polar(theta = "y", start = 0)+
  geom_text(aes(y = Fl, label = V4), color = "white")+
  scale_y_continuous(breaks=min(df$Fl):max(df$Fl)) +
  scale_fill_manual(values = mycols) +
  theme_void()+
  xlim(0.5, 2.5)

This generates enter image description here

So, I got only one column displayed.

The other trial used this:

pie(x=c(88.58,7.33,1.55,2.2),labels="",
col=c("#eee0b1", "#da8a67", "#e63e62", "#0033aa"))
par(new=TRUE)
pie(x=c(81.43,15.34,1.94, 1.25),labels=c("Proteobacteria","Firmicutes","Actinobacteriota", "Bacteroidota"),radius=.5,
    col=c("#eee0b1", "#da8a67", "#e63e62", "#0033aa"))

that generates this figure: enter image description here

I do not know which is easier to fix to generate the concentric pie. I need to include the color legend and label each pie with the category name (V4, Fl) along with adding the values as percentages.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source