0

I have created a multiple pie chart plot. These are the codes -

Title = c("Male","Male","Male", 
      "Female","Female","Female", 
      "Both", "Both","Both")
BDD_Level = c('Subclinical BDD','Mild-Moderate BDD','Moderate-Severe BDD',
          'Subclinical BDD','Mild-Moderate BDD','Moderate-Severe BDD',
          'Subclinical BDD','Mild-Moderate BDD','Moderate-Severe BDD')
value = c(0.90, 0.09, 0.01,
      0.84, 0.14, 0.02,
      0.87, 0.11, 0.02)
piec<-data.frame(Title,BDD_Level,value)

ggplot(piec, aes("", value, fill = BDD_Level)) +
geom_bar(stat = "identity", size = 3) +
geom_text(aes(label = paste0(value * 100, "%")), 
        position = position_stack(vjust = 0.5), 
        color = "white", size = 4) +
 coord_polar(theta = "y") +
  facet_wrap(~ Title, nrow = 1) +
  scale_fill_manual(values = c("#d45087", "#f95d6a","#ffa600"
                           )) +
  theme_void()+

enter image description here

So, I want to place the pie chart entitled "Both" the very right side of this plot and bring the "Male" pie chart to the very left side of this plot.

Also,If I use nrow=2 function. How do I bring the plot of the 2nd row from side to the middle?

  • 1
    Note indicates this question is answered [here](https://stackoverflow.com/questions/14262497/fixing-the-order-of-facets-in-ggplot) already, but that doesn't answer your second question. The second question about how to center the second line of a faceted plot should be one of the answers posted [here](https://stackoverflow.com/questions/51010990/r-ggplot2-setting-the-last-plot-in-the-midle-with-facet-wrap). I like the one using the `egg` package visually, but up to you. – chemdork123 Apr 07 '20 at 12:31
  • Thanks dear. It works. Can you please guide me, how do I increase the size of the "Male", "Female" and "Both" title of each of the pie chart? – Shakil Ahmed Shaon Apr 07 '20 at 13:18
  • Facet label formatting is accessed via `strip.text` ([one of the theme elements](https://ggplot2.tidyverse.org/reference/theme.html)). You need to specify it as an `element_text`, so the full call would be something like this added to your `ggplot` object: `theme(strip.text = element_text(size = ...)`. You can format style, etc as mentioned within the [documentation for the `element_text` function](https://www.rdocumentation.org/packages/ggplot2/versions/1.0.0/topics/element_text). – chemdork123 Apr 07 '20 at 14:18
  • Forgot the closing `)`... I'm sure you can figure that out though :) – chemdork123 Apr 07 '20 at 14:39

0 Answers0