vegandevs / vegan

R package for community ecologists: popular ordination methods, ecological null models & diversity analysis
https://vegandevs.github.io/vegan/
GNU General Public License v2.0
443 stars 96 forks source link

Introducing jitter into plot #406

Open RebeccaVal opened 3 years ago

RebeccaVal commented 3 years ago

Hello,

I'm trying to use your R vegan package for a community composition analysis of marine species. :)

I pass my data into decorana function. I then pass that into the plot function, and it works ok. However, some points overlap, and I'd like to introduce some jitter so it's clear when there are multiple points at one spot. ggplot is able to introduce jitter with an argument, but, when I pass in the data returned from the decorana function into ggplot, I get the message: "data must be a data frame, or other object coercible by fortify(), not an S3 object with class decorana."

If could give me a pointer, it would really help me. Thank for the excellent software.

gavinsimpson commented 3 years ago

You could extract the scores you want to plot and add jitter to them using jitter() and then plot them, to stay within the base graphics paradigm. If you want to go to {ggplot2} then you could use the {ggvegan} package which is currently on GitHub here: https://github.com/gavinsimpson/ggvegan which has a fortify and autoplot methods

jarioksa commented 3 years ago

This is a matter of taste, but I don't like jitter in ordination plots: we work hard to get the numbers right and we do not want them be jittered (that will sink eigenvalues). For ggplot2 graphics I rather suggest using alpha channel for colours so that the points will be darker if they are overlaid. In conventional graphics you can also use sunflowerplot (see its help) for the same purpose.