0
votes

I need to plot a pie chart as below: it must be colored by the same color but with scaled intensity.

enter image description here

Then In my case of use, I have this data frame :

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)

And as given here, I tried to plot my pie chart as given below.

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

But I get this error that I can't resolve it:

Error: object 'blank_theme' not found

What should I do, please?

2
I strongly recommend you adhere to established norms and program in English. Meaning all your identifiers and comments in code should be English, not localised. - Konrad Rudolph
@KonradRudolph, it gives the same error Error: object 'theme_blank' not found - Rprogrammer
Have you defined blank_theme anywhere? If not, you can't call something that hasn't been defined. But you're asking about both the theme and the coloring of the plot—these are separate issues handled by separate functions. Which are you really trying to address? - camille

2 Answers

2
votes

blank_theme should be theme_blank(). However, this function is now defunct (and thus no longer exists). It has been replaced by theme_bw() or theme_minimal().

1
votes

try this code, it works for me.

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