I am analyzing the ecological data atm, so I do like to draft a CCA plot that contains information about sites, spp, and environmental variables data. And also coloring geom_text related to the sites and spp separately? Is there any codes enables me to do so in the ggplot2?
I had tried to add two geom_text(spp and sites variables) in the single phrase of codes, but it does not work out as I expected since the geom_text from these two variables are overlapping each other. And then I did try to add colors to geom_text separately, but it does not work out as well. I tried to plot the graph using the auto_plot function of ggvegan, I like the graph the way it orientates the colors and word size of the graph, but the texts were overlapping.
ggplot() +
geom_point(aes(x=CCA1, y=CCA2), data=filter(vare_tbl, ccatype=="species"))+ geom_text_repel(aes(x=CCA1, y=CCA2, label=vgntxt, size=3.5),
data=vare_tbl, seed=123) +
geom_text_repel(aes(x=CCA1, y=CCA2, label=vgntxt, size=3.5),
data=vare_sam_tbl, seed=123)+
geom_segment(aes(x=0, y=0, xend=CCA1, yend=CCA2), arrow=arrow(length = unit(0.2,"cm")),
data=filter(vare_tbl, ccatype=="bp"), color="blue") +
coord_fixed() +
scale_colour_manual(values = c("blue", "black"))+ #this code isn't working
theme_classic() +
theme(legend.position="none")
##Autoplot function of ggvegan
autoplot(cca2, arrows = TRUE, geom = "text", legend = "none")
I obtained the codes to plot the biplot graph from https://blogs.ncl.ac.uk/mep/2018/04/08/reproducible-publication-quality-multivariate-plots-in-r/.
And I obtained the codes to color up the geom_text from https://ggplot2.tidyverse.org/reference/geom_point.html, by doing so the factor(cyl) wasn't work out for me.