1

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")
Phil
  • 7,287
  • 3
  • 36
  • 66
N.B
  • 15
  • 2
  • It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick May 17 '22 at 13:00
  • 1
    Difficult to say without a reproducible example, but try `y = 1` instead of `y = "1"` – Allan Cameron May 17 '22 at 13:01

1 Answers1

2

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")
Lucca Nielsen
  • 1,497
  • 3
  • 16