Search code examples
rdataframecoordinates

R arrow/direction plot from Data.frame


i am experimenting with different plots. I have a data.frame that looks like this:

Date/Time               X       Y
22.06.2016 08:44    12.033  6.440
22.06.2016 08:44    12.062  6.428
22.06.2016 08:45    12.189  6.538
22.06.2016 08:45    12.084  6.455
22.06.2016 08:46    12.069  6.443
22.06.2016 08:46    12.070  6.301
22.06.2016 08:47    12.025  6.298

I managed to make a heatmap on a custom background in relation to the density of X/Y coordinates like "many records where made here, but less here".

I would like to experiment with plotting some sort of walkways/trails from x0,y0 to x1,y1 then x1,y1 to x2,y2 and so on (in a perfect world, it should look like a snake on the "ground").

Considering there is only a very small distance between x0y0 and x1y1 this might look a little odd, but I would like to try anyway. I tried something with arrows(), but the result did not work at all.


Solution

  • arrows worked for me, although it is an odd path.

    plot(df[,2:3])
    arrows(df[-nrow(df), 2], df[-nrow(df), 3], 
        df[-1, 2], df[-1, 3], length=0.1)
    

    enter image description here