I`m trying to plot a function using the ggplot2 package in R but I'm stuck with having the y-axis at its "usual" position. So right now my plot looks like this:
although it should look like this:
Sorry for the bad painting btw, I hope you get the idea.
Do you have any ideas, how to create while with keeping the arrow at the end of the y-axis?
My code:
library(ggplot2)
a <- 1
x <- seq(-2,4,1/100)
y <- pnorm(x,a,1)
dat <- data.frame(x=x,y=y)
dat2 <- data.frame(x=a,y=seq(0,1,1))
ggplot(dat,aes(x=x,y=y))+
geom_line()+
theme_minimal()+
labs(y="F")+
geom_line(data = dat2, aes(x=x,y=y),linetype = "dashed")+
geom_text(aes(x=a+0.1,y=0.4),label = "a")+
theme(axis.line.x = element_line(arrow=arrow(length = unit(3, 'mm'))),
axis.line.y=element_line(arrow = arrow(length = unit(3, 'mm'))
)
) +
scale_x_continuous(expand = c(0, 0), limits = c(-2, 4)) +
scale_y_continuous(expand = c(0, 0),limits = c(0, 1))
Thanks a lot!