changing the size of the plot when its a catergorical x axis

I want to reduce the plot size of my graph, in order to reduce the space either side of my lines. How could I do this using ggplot2.

I want the plot width to be something like what is in the red square
image

Thanks

You can use expand() to tweak your scale limits

library(ggplot2)

ggplot(iris, aes(Species, Sepal.Width)) +
    geom_point()


ggplot(iris, aes(Species, Sepal.Width)) +
    geom_point() +
    scale_x_discrete(expand = c(0.05,0.05))

Created on 2019-04-07 by the reprex package (v0.2.1.9000)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.