Note that there are some explanatory texts on larger screens.

plurals
  1. POPlotting ordiellipse function from vegan package onto NMDS plot created in ggplot2
    primarykey
    data
    text
    <p>Instead of the normal plot function I am using <code>ggplot2</code> to create NMDS plots. I would like to display groups in the NMDS plot using the function <code>ordiellipse()</code> from the <code>vegan</code> package. </p> <p>Example data:</p> <pre><code>library(vegan) library(ggplot2) data(dune) # calculate distance for NMDS sol &lt;- metaMDS(dune) # Create meta data for grouping MyMeta = data.frame( sites = c(2,13,4,16,6,1,8,5,17,15,10,11,9,18,3,20,14,19,12,7), amt = c("hi", "hi", "hi", "md", "lo", "hi", "hi", "lo", "md", "md", "lo", "lo", "hi", "lo", "hi", "md", "md", "lo", "hi", "lo"), row.names = "sites") # plot NMDS using basic plot function and color points by "amt" from MyMeta plot(sol$points, col = MyMeta$amt) # draw dispersion ellipses around data points ordiellipse(sol, MyMeta$amt, display = "sites", kind = "sd", label = T) # same in ggplot2 NMDS = data.frame(MDS1 = sol$points[,1], MDS2 = sol$points[,2]) ggplot(data = NMDS, aes(MDS1, MDS2)) + geom_point(aes(data = MyMeta, color = MyMeta$amt)) </code></pre> <p>How can I add ordiellipse to the NMDS plot created with <code>ggplot2</code>?</p> <p>Didzis Elferts' answer below works great. Thank you! However, I am now interested in plotting the following ordiellipse to the NMDS plot created with <code>ggplot2</code>:</p> <p><code>ordiellipse(sol, MyMeta$amt, display = "sites", kind = "se", conf = 0.95, label = T)</code></p> <p>Unfortunately, I don't understand enough about how the <code>veganCovEllipse</code> function works to be able to adjust the script myself. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload