This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Ggplot2: Plot X Axis As Y= 0 Line

Salutations:

I'm making a figure in R using ggplot2, I actually have a copy of the R Graphics Cookbook, but they seemed to neglect any option to move the X axis to the origin.

Please look at this figure to see what exactly I need help with

This is how I dealt with it in base R

> plot(..., xant='n")
> axis(0,pos=1)

But I'm a little lost in ggplot2

Tusen takk.

r data

1) This has nothing to do with bioinformatics (try an R forum), so I'll close the post. 2) You R code wouldn't even work, since the bottom axis is 1, not 0, and you meant xaxt rather than xant.

Edit: I'll add that the trick is something like:

x <- seq(10,200,10)
y <- runif(x)-0.5
d <- data.frame(x=x,y=y)
g <- ggplot(d, aes(x=x,y=y))
g <- g + geom_point()
g <- g + theme_bw()
g <- g + theme(panel.grid=element_blank(), panel.border=element_blank(), axis.line=element_line(), axis.line.x=element_blank())
g <- g + geom_abline(intercept=0, slope=0)
g

Edit2: See also this issue report.

0 answers

No answers yet.

Log in to answer this question.