Adding an arrow below the x axis in R plots

后端 未结 2 1907
慢半拍i
慢半拍i 2020-12-31 17:12

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

2条回答
  •  生来不讨喜
    2020-12-31 18:01

    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.

提交回复
热议问题