-4

I am attempting to produce an NMDS plot in vegan, but really struggling with the code. I am trying to display the site points and species points differently, with the site points coloured according to treatment. Both lines work individually, but I cannot work out how to combine these two lines of code into one line to form one graph. I am using ordipointlabel to prevent overlap. These are the two lines of code I want to combine into one.

ordipointlabel(NMDS10, scaling=2, display="species", select=sel) 
ordipointlabel(NMDS10,display="sites", col=c(rep("darkgreen",4),rep("blue4",4)),cex=0.75)
Hack-R
  • 22,422
  • 14
  • 75
  • 131
  • 1
    Welcome to StackOverflow! For code debugging please always ask with a [reproducible](https://stackoverflow.com/q/5963269/1422451) example per the [MCVE](https://stackoverflow.com/help/mcve) and [`r`](https://stackoverflow.com/tags/r/info) tag description, with the desired output. You can use `dput()`, `reprex::reprex()` or built-in data sets for reproducible data. – Hack-R Aug 02 '18 at 12:34
  • 1
    It seems that you're asking things that are not yet implemented in `ordipointlabel`(contributions welcome!): you can have two kind of scores in *one* `ordipointlabel` command (`display = c("sites", "species")`), but then you cannot have `select`, and also you can only have one `col` argument for each time (one `col` for `species`, another for `sites`). This at least I can gather from documentation. – Jari Oksanen Aug 02 '18 at 19:15

1 Answers1

0

You can access directly to ordinpointlabel object and make it look like you wish. Please see the sample:

library(vegan)
data(dune)

NMDS10 <- metaMDS(dune[1:8, ])

pdf(file = NULL)
y <- ordipointlabel(NMDS10, display=c("sites", "species"))
dev.off()

# select  sites & species
sel <- unlist(dimnames(dune[1:8, ]))[-(20:ncol(dune))]

# messing with ordipointlabel object
y$points <- y$points[rownames(y$points) %in% sel, ]
y$args$pcol[] = rep("red", length(y$args$pcol))
y$args$pcol[1:8] <- c(rep("darkgreen", 4), rep("blue4", 4))
y$par$cex <- 0.75

plot(y)

NMSDN

Artem
  • 3,304
  • 3
  • 18
  • 41