错误:找不到对象“ blank_theme”

时间:2018-07-31 14:44:23

标签: r ggplot2

我需要绘制一个饼图,如下所示:它必须用相同的颜色上色,但强度要缩放。

enter image description here

然后在我使用的情况下,我具有以下数据框:

library(ggplot2)

régions<-c("Bouches-du-Rhône","Paris","Nord","Hauts-de-Seine",
           "Circonscription départementale du Rhône","Haute-Garonne","Bas-Rhin","Loire-Atlantique",
           "Seine-Maritime","Pas-de-Calais")


Pourcentages<-c(15.2,15.2,12.3,10.1,9.7,8.4,7.7,7.5,7.2,6.8)
length(Pourcentages)

Data<-data.frame(régions,Pourcentages)

然后按照给定的here,尝试绘制如下的饼图。

bp<- ggplot(data, aes(x="", y=Pourcentages, fill=régions))+
  geom_bar(width = 1, stat = "identity")

pie <- bp + coord_polar("y", start=0)


pie + scale_fill_brewer("Blues") + blank_theme+
  theme(axis.text.x=element_blank())+
  geom_text(aes( y=Pourcentages, 
                label = Pourcentages, size=5))

但是我收到无法解决的错误:

  

错误:找不到对象“ blank_theme”

我该怎么办?

2 个答案:

答案 0 :(得分:1)

尝试此代码,它对我有用。

régions<-c("Bouches-du-Rhône","Paris","Nord","Hauts-de-Seine",
       "Circonscription départementale du Rhône","Haute-Garonne","Bas-Rhin","Loire-Atlantique",
       "Seine-Maritime","Pas-de-Calais")


Pourcentages<-c(15.2,15.2,12.3,10.1,9.7,8.4,7.7,7.5,7.2,6.8)
Data <-data.frame(régions,Pourcentages)


bp<- ggplot(Data, aes(x="", y=Pourcentages, fill=régions)) +
 geom_bar(width = 1, stat = "identity") 

pie <- bp + coord_polar("y", start=0)
p <- pie + scale_fill_brewer("Blues") + theme_bw()

enter image description here

答案 1 :(得分:1)

blank_theme应该是theme_blank()。但是,此功能现已失效(因此不再存在)。它已被theme_bw()theme_minimal()取代。