使用 text = element_blank() 时,将标题添加到 ggplot 饼图

Add a title to a to a ggplot pie chart when text = element_blank() is used

我想制作一个饼图没有任何标签,但是一个标题。

但是,我无法同时满足这两个要求:或者我有一个没有标题和轴的饼图(左图),或者我有一个有标题和轴的饼图(右图)。见下图:

是否可以左图加标题,或者右图去掉坐标轴?

数据

data<-structure(list(nuts0 = c("IT", "IT", "IT", "IT", "IT", "IT", 
                         "IT", "IT", "IT", "IT"), variable = structure(1:10, .Label = c("percentage_irri10", 
                                                                                        "percentage_irri20", "percentage_irri30", "percentage_irri40", 
                                                                                        "percentage_irri50", "percentage_irri60", "percentage_irri70", 
                                                                                        "percentage_irri80", "percentage_irri90", "percentage_irri100"
                         ), class = "factor"), value = c(0.100915431560593, 0.0860941586748038, 
                                                         0.0695292066259808, 0.0662598081952921, 0.0745422842197036, 0.0512205754141238, 
                                                         0.0599389712292938, 0.047079337401918, 0.0551438535309503, 0.389276373147341
                         )), .Names = c("nuts0", "variable", "value"), row.names = c(10L, 
                                                                                     25L, 40L, 55L, 70L, 85L, 100L, 115L, 130L, 145L), class = "data.frame")


percentlabelsIT<- round(100*data$value, 0)
pielabelsIT<- paste(percentlabelsIT, "%", sep="")
cols <- c("yellow","greenyellow","#00FF00", "#00C639","#00AA55", "#00718E", "#0055AA", "#001CE3","blue4","midnightblue")

饼图

pie <- ggplot(data, aes(x = factor(1), fill = factor(percentlabelsIT))) + geom_bar(width = 1)+
  ggtitle("help")+
  theme(axis.text = element_blank(),
        axis.ticks = element_blank(),
        panel.grid  = element_blank(),
        legend.position="none",
        line = element_blank(),
        text = element_blank()
  )+
  scale_fill_manual(values=cols)
l1<-pie + coord_polar(theta = "y")
l1

试试这个(没有 text= 但有 axis.titleggtitle):

pie <- ggplot(data, aes(x = factor(1), fill = factor(percentlabelsIT))) + geom_bar(width = 1)+
    ggtitle("help")+
    theme(axis.text = element_blank(),
          axis.title = element_blank(),
          axis.ticks = element_blank(),
          panel.grid  = element_blank(),
          legend.position="none",
          line = element_blank()
    )+
    scale_fill_manual(values=cols)
l1 <-pie + coord_polar(theta = "y") + ggtitle("kdfja")
l1