How could I increase the space between the y-axis line and the first bar in the following bar plot?
# Load ggplot
library(ggplot2)
# Load the Titanic dataset
data("Titanic")
Titanic <- as.data.frame(Titanic)
# Bar plot
ggplot(Titanic, aes(x = Class, y = Freq, fill = Survived)) +
geom_col(position = "fill") +
coord_cartesian(ylim = c(0, 1), expand = FALSE) +
theme_classic() +
theme(legend.position = "none",
axis.line.x = element_blank(),
axis.ticks.x = element_blank())
Is there a way to apply coord_cartesian(expand = FALSE) only to the x-axis? This could resolve the problem.

I don't think you can get that level of control with
coord_cartesion. You can use the scales insteadChange the value of .8 to whatever you like.