首页 > 解决方案 > 如何自定义多图饼图的“单饼图”位置?

问题描述

我创建了一个多饼图。这些是代码 -

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()+

在此处输入图像描述

因此,我想将标题为“Both”的饼图放在该图的最右侧,并将“Male”饼图放在该图的最左侧。

另外,如果我使用nrow=2功能。如何将第二行的情节从一侧带到中间?

标签: rggplot2pie-chart

解决方案


推荐阅读