EcologyTom - 1 year ago 101

R Question

I would like to include two horizontal lines using geom_hline in ggplot. The scale on my graph runs from 0 to 20,000 and I would like to have single lines at 400 and 17,000.

`?geom_hline`

`geom_hline(yintercept = 20)`

`(geom_hline(yintercept = 1:5)`

So

`geom_hline(yintercept = 400: 17000)`

`400, 401, 402`

`geom_hline(yintercept = 400, 17000)`

`:`

`,`

Answer Source

I simulated some `rnorm x<-rnorm(500); d<-data.frame("x"=x,"den"=dnorm(x))`

and plot them as a line, it works fine..is your data in data.frame?

Does this work for you if you simulate the values?

```
ggplot(d,aes(x,den))+geom_line()+geom_hline(yintercept = c(0.1,0.2))
```