This should be simple but I can't find the answer. All I want to do is add a line to a plot drawn at a specific y value starting at a specific x value and ending at a specific x value. The abline function doesn't seem to have a start and end parameter. How do I do this in r for normal (non ggplot) plots
Asked
Active
Viewed 876 times
0
-
1`abline(h=pvalue)` for a horizontal line at the p-value – Marc in the box Apr 20 '15 at 07:55
-
3Do you mean drawing a `segment`? – Apr 20 '15 at 07:56
-
Yes that worked. I guess in the end its about finding the right word to google. I used this---par(lend=2);segments(1,37,2,37,lwd=6) – Sebastian Zeki Apr 20 '15 at 08:04
-
1Or `lines()`, where you simply repeat your y value twice. – Stephan Kolassa Apr 20 '15 at 08:29
-
This seems to be asked before: http://stackoverflow.com/questions/29263046/how-to-draw-the-boxplot-with-significant-level/29263992#29263992 – Ruthger Righart Apr 20 '15 at 08:47
-
Nope. thats for ggplot. This is for base plots – Sebastian Zeki Apr 20 '15 at 21:55
1 Answers
1
In a general case, to plot a line from point (x_1, y_1)
to point (x_2, y_2)
, simply use lines(c(x_1, x_2), c(y_1, y_2))

ClementWalter
- 4,814
- 1
- 32
- 54