I wanna make one plot, but there is no 'January' displayed in the legend, I have no idea which place is wrong in my code!!! Thanks all!!!
ZHnMDS1 = metaMDS(data)
ZHnMDS1_scores = as.data.frame(scores(ZHnMDS1))
ZHnMDS1_scores$grp = MB$Month
ZHfind_hull <- function(df)
df[chull(df$NMDS1, df$NMDS2),]
library(plyr)
ZHhulls <- ddply(ZHnMDS1_scores, "grp", ZHfind_hull)
ZHnMDS1_scores$TEAM = MB$TEAM
library(ggplot2)
ZHnMDS_scores = read.csv("Desktop//ZHnMDS_scores.csv")
ggplot(ZHhulls, aes(NMDS1, NMDS2)) +
geom_polygon(data = ZHhulls,
aes(
x = NMDS1,
y = NMDS2,
fill = factor(grp),
group = grp
),
alpha = 0.09) + #fill change color
geom_point(
data = ZHnMDS1_scores,
aes(x = NMDS1, y = NMDS2),
size = 0.8,
alpha = 0.1
) +
geom_path(aes(x = NMDS1, y = NMDS2, color = factor(TEAM)), ZHnMDS_scores) +
#color change color
theme_bw() +
theme(
panel.background = element_blank(),
panel.grid.major = element_blank(),
#remove major-grid labels
panel.grid.minor = element_blank(),
#remove minor-grid labels
plot.background = element_blank()
) +
scale_fill_discrete(breaks = c(
"October",
"November",
"December",
"January",
"February",
"March",
"April"
)) + labs(color = "Final", fill = "Month")