geom_abline does not work

395 views
Skip to first unread message

Daniel Lincke

unread,
Mar 11, 2014, 7:13:39 AM3/11/14
to ggp...@googlegroups.com
Hi all,

did anybody ever use geom_abline? It always draws a vertical line trough
zero ... thats not what it is inteded to do, right?

I treide the following versions:

geom_abline()
geom_abline(intercept=1,slope=2)
geom_abline(aes(intercept=1,slope=2))
geom_abline(intercept=1)

result is always the same.

Why?

Thanks.

Roman Luštrik

unread,
Mar 11, 2014, 7:33:18 AM3/11/14
to Daniel Lincke, ggplot2
Can you give us a reproducible example? It should draw a line that intersects y at specified height when x = 0 and with a certain slope. You can code this manually as you did in the second example or map it to a variable(s) as you did in the third example.

Can  you give us an example of what you're experiencing and perhaps what you're trying to achieve?

Cheers,
Roman




--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+unsubscribe@googlegroups.com
More options: http://groups.google.com/group/ggplot2

--- You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
In God we trust, all others bring data.

Dennis Murphy

unread,
Mar 11, 2014, 5:20:38 PM3/11/14
to Daniel Lincke, ggplot2
Here's a reproducible example:

library(ggplot2)
DF <- data.frame(x = rnorm(10), y = rnorm(10))

ggplot(DF, aes(x = x, y = y)) + geom_point() +
geom_abline(intercept = -0.5, slope = 0.7, color = "blue") +
geom_hline(yintercept = 0, linetype = "dotted") +
geom_vline(xintercept = 0, linetype = "dotted")

This works on my system:

> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
<snip>

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] ggplot2_0.9.3.1

loaded via a namespace (and not attached):
[1] colorspace_1.2-4 dichromat_2.0-0 digest_0.6.4 grid_3.0.2
[5] gtable_0.1.2 labeling_0.2 MASS_7.3-29 munsell_0.4.2
[9] plyr_1.8 proto_0.3-10 RColorBrewer_1.0-5 reshape2_1.2.2
[13] scales_0.2.3 stringr_0.6.2

It's more helpful to provide an example with data and code that
illustrates your problem than to claim "it doesn't work". Session
info such as that provided above can also be informative, so please
include that as well.

Dennis
> --
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
> --- You received this message because you are subscribed to the Google
> Groups "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ggplot2+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages