I’m trying to remove the space between the y-axis line and the first tick mark in my plot. Here’s an example:
set.seed(201)
n <- 100
dat <- data.frame(xval = (1:n+rnorm(n,sd=5))/20, yval = 2*2^((1:n+rnorm(n,sd=5))/20))
dat[dat[,1] < 0,1] <- 0
dat[dat[,2] < 0,2] <- 0
ggplot(dat, aes(xval, yval)) + geom_point()
This code plots a graphic with a space between the y-axis line and the zero tick mark in the x-axis. How can I remove it?
You can alter this “gap” using the
scale_x_continuousfunction:From the help file on
scale_x_continuous,To alter the space on the y-axis, use
scale_y_continuous