Home > Back-end >  Removing the white bar in barplot with ggplot2
Removing the white bar in barplot with ggplot2

Time:05-20

Im trying to remove the white bar on the right of this barplot, but i cannot understand how. Here is the graph:

Here is the code i used:

library(ggplot2)    
ggplot(data = df2, aes(x=`neighbourhood`, y="1", fill=`room_type`)                                                                    
 geom_bar(position="fill", stat="identity")  
 coord_flip()  
 scale_fill_brewer(palette = 14)  
 labs(title = "Tipi di stanze per quartiere", y = "Quantità", x = "Quartiere", fill = "Tipo di stanza")

CodePudding user response:

Try removing the y = "1" and the stat = "identity", like this:

library(ggplot2)    
    ggplot(data = df2, aes(x=`neighbourhood`, fill=`room_type`)                                                                    
     geom_bar(position="fill")  
     coord_flip()  
     scale_fill_brewer(palette = 14)  
     labs(title = "Tipi di stanze per quartiere", y = "Quantità", x = "Quartiere", fill = "Tipo di stanza")
  • Related