我的数据集很小
cent<-structure(list(temporal = structure(c(3L, 6L, 1L, 7L, 5L, 4L,
2L), .Label = c("April", "August", "February", "July", "June",
"March", "May"), class = "factor"), NMDS1 = c(0.0974540266588284,
0.1688532488445, 0.0468643826727811, 0.0355451066297488, -0.0209516885503105,
-0.206936981483144, -0.120828094772404), NMDS2 = c(-0.0101014005049961,
0.030236007628167, -0.388205968271465, -0.166511878199233, -0.0172718994833608,
0.321810567323985, 0.230044571506903)), row.names = c(3L, 6L,
1L, 7L, 5L, 4L, 2L), class = "data.frame")
此数据表示每月nmds分析的质心位置。我想用ggplot绘制它(很简单):
ggplot(cent, aes(x = NMDS1, y = NMDS2, colour = factor(temporal, levels = month.name))) +
geom_line(arrow = arrow()) +# spiders
geom_point(data = cent, size = 5) +
geom_point() +
coord_fixed() + theme_classic()
但是我想画一条箭头连接所有点(按月顺序),以显示这些质心随时间的变化。我还无法弄清楚该怎么做,我将其放入MS paint中并在那里进行。任何帮助都会真正帮助您!
仅在某些情况下,我每月对昆虫进行抽样(每月10个相同的地点),并对数据进行非度量的多维标度分析。我根据数月计算了质心,并希望显示社区随着时间推移而发生的变化和变化。
答案 0 :(得分:1)
library(ggplot2); library(dplyr)
ggplot(cent, aes(x = NMDS1, y = NMDS2, colour = factor(temporal, levels = month.name))) +
geom_line(arrow = arrow()) +# spiders
geom_point(data = cent, size = 5) +
geom_segment(aes(xend = lead(NMDS1), yend = lead(NMDS2)),
arrow = arrow(length = unit(0.05,"npc"), type = "closed")) +
coord_fixed() + theme_classic()