Search code examples
rscatter-plotveganline-segment

How to connect several points with an arrow omitting ggplot2


I made an ordination of a time series of some vegetation data, using the vegan package. Since ordination diagrams often are cluttered with many data points, I extracted the eigenvalues of the first two ordination axes and took the mean of each group. Now I have only one point per site (11 sites total) To still show some of the variation, I added ellipses with standard deviation and 95% confidence interval: enter image description here

The last thing I want to do is to connect points of the same group (either A, B or C) with an arrow, indicating direction of change over time. All movement is from right to left.

I initially wanted to use the ordiarrow function in vegan, but this works only when class is decorana. My class is a factor.

Using ggplot2 does not seem like a valid option as the ordiellipse function (creating the ellipses) does not work there.

code for plotting data:

install.packages("vegan")
library(vegan)
plot(Ord_KIKKER, type = "n", main = "Kikkervalleien",
     xlab = "DCA1 Eigenvalue = 0.62", ylab = "DCA2 Eigenvalue = 0.39")


points(ORD_KIKKER, cex = 2, pch = 19,
       col = c("black", "black", "black", "red","red", "green", "green", "green", "blue", "blue", "blue"))

The resulting plot looks a bit different since I posted a reduced dataset here.

My data (Ord_KIKKER):

structure(list(DCA1 = c(2.676616032, 0.361181861, -1.363464067, 
3.176862449, -0.087190269, 2.059548542, 0.167440366, -0.459090096, 
1.571536367, 0.309623788, -0.25787459), DCA2 = c(0.276788721, 
0.422077659, 0.181723453, 0.221610649, 0.940063655, -0.116083905, 
-0.539375059, -0.545053063, -0.06120542, -0.367148924, -1.679257818
), Unique = structure(c(1L, 5L, 8L, 2L, 9L, 3L, 6L, 10L, 4L, 
7L, 11L), .Label = c("2001A", "2001B", "2001C", "2001D", "2008A", 
"2008C", "2008D", "2018A", "2018B", "2018C", "2018D"), class = "factor"), 
    BLOCK = structure(c(1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 
    4L), .Label = c("A", "B", "C", "D"), class = "factor")), .Names = c("DCA1", 
"DCA2", "Unique", "BLOCK"), class = "data.frame", row.names = c("2001A", 
"2008A", "2018A", "2001B", "2018B", "2001C", "2008C", "2018C", 
"2001D", "2008D", "2018D"))

Solution

  • vegan::ordiarrows() will work, if you give it only the variables that have scores:

    ordiarrows(Ord_KIKKER[,1:2], Ord_KIKKER$BLOCK) # one way
    

    However, you should also remember to have asp=1 in the initial plot to force equal aspect ratio to axes.

    I cannot do full testing, because the graph cannot be reproduced with the data you posted: If you issue plot(Ord_KIKKER, ...) with a data frame, you will not get ordinary plot, but a panel plot of all variables against each other (pairs() plot), and also give an error for type = "n" argument. It seems that you instead used some non-standard graphics tools, and I am not sure that standard R graphics of vegan::ordiarrows() can be combined with those.