0

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.

enter image description here

neilfws
  • 32,751
  • 5
  • 50
  • 63
  • 1
    Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not use `str()`, `head()` or screenshot)? You can use the [`reprex`](https://reprex.tidyverse.org/articles/articles/magic-reprex.html) and [`datapasta`](https://cran.r-project.org/web/packages/datapasta/vignettes/how-to-datapasta.html) packages to assist you with that. See also [Help me Help you](https://speakerdeck.com/jennybc/reprex-help-me-help-you?slide=5) & [How to make a great R reproducible example?](https://stackoverflow.com/q/5963269) – Tung Mar 25 '19 at 01:10
  • Here I share the links to my biotic and abiotic datasets that I been used to analyze using cca() function of vegan package. I standardized the biotic data using method "logbase" of decostand, while method "Hellinger" for environmental data. https://drive.google.com/file/d/1rKlVIDoWK-gSmGhAwjQhbD2HKRzK53Af/view?usp=sharing (Biotic data); https://drive.google.com/file/d/1u7CRIofasfZEMAG8kn4iDQ6Wj9oVOFOx/view?usp=sharing (abiotic data). Any helps would be forwarded with thanks in advance from me. – Monkey D. Luffy Mar 25 '19 at 14:51
  • 1
    Please read the links I posted and create a `reprex`. Google Drive or other sharing platforms are usually not recommended as users could later delete their files and make their questions not reproducible for future readers – Tung Mar 25 '19 at 20:02

0 Answers0