Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding an arrow below the x axis in R plots

Tags:

plot

r

I am trying to add arrows marking specific x coordinates below the x axis in an R plot. My x axis is at y=0 and when I try to use negative y-coordinates in arrows, so the arrows will be perpendicular to x axis, I get only the very edges of the arrow plotted (although is some space, e,g where the x-axis label and tickmarks are plotted).

like image 900
David B Avatar asked Aug 06 '10 09:08

David B


1 Answers

The xpd option can be used in arrows so you can just set your coordinates to be outside your plot region and set xpd to TRUE. For example, assuming xlim = c(0,10) and ylim = (0,10), and you set the x-axis to 0 then

arrows(1.4, -1, 1.4, 0, xpd = TRUE)

draws a vertical arrow pointing up at the x-axis at position 1.4 on that axis.

like image 137
John Avatar answered Oct 19 '22 17:10

John