0

When I use coord_flip in ggplo2 using this code

# rotate to make more readable
p1 <- ggplot(mtcars, aes(x = row.names(mtcars), mpg)) +
        geom_bar(stat = "identity") +
        coord_flip() +
        ggtitle("Fig. A: Default rotated x-axis")

# order bars
p2 <- ggplot(mtcars, aes(x = reorder(row.names(mtcars), mpg), y = mpg)) +
        geom_bar(stat = "identity") +
        coord_flip() +
        ggtitle("Fig. B: Rotated ordered x-axis")

grid.arrange(p1, p2, ncol = 2)

I get the following chart

I have highlighted the space that exists next to y axis, PLease can you help me understand how I can remove that.

rawr
  • 20,481
  • 4
  • 44
  • 78
Vik G
  • 539
  • 3
  • 8
  • 22
  • 3
    add `scale_y_continuous(expand = c(0, 0))` and this should be fixed. – Amar May 17 '18 at 22:17
  • https://stackoverflow.com/questions/22945651/how-to-remove-space-between-axis-area-plot-in-ggplot2 – rawr May 17 '18 at 22:18

0 Answers0