0

Here is my code

library(vegan)
library(MASS)


row.names(Data) <- c("SI1", "SII0", "SI0", "SII2", "SI2", "SII1", "SIII0", "SIV2", "SIII2", "SIV1", "SIII1", "SIV0")
bcdist <- vegdist(Data, "bray")

bcmds <- isoMDS(bcdist, k = 2)


plot(bcmds$points, type = "n", xlab = "", ylab = "")

text(bcmds$points, dimnames(Data)[[1]])

Then I get this graph. How do I add colors for every point in the graph? Thank you

Here is my data

Mr Good News
  • 121
  • 1
  • 3
  • 15

1 Answers1

1

Specify a colour for each point/group or use a pre-made colour pallet (must be at least as long as your number of groups):

cols <- c("red", "blue", "green"....etc)

Then include the col argument in the plotting function, choosing a label colour based on your row names:

text(bcmds$points, dimnames(Data)[[1]], col = cols)
David Foster
  • 447
  • 4
  • 16
  • ... and **absolutely** remember to use argument `asp = 1` in your `plot()`. It takes care of isometric scaling of your graph, and that is important in ordination plots (not the least as you are using **iso**MDS). – Jari Oksanen Feb 22 '18 at 13:14
  • @David Foster Thank you for the quick reply but it didnt change the color. Still got the same graph – Mr Good News Feb 22 '18 at 13:37
  • @David Foster here is my code > cols <- c("red", "blue","blue", "green","green","red","blue","green","green","red","red","blue") – Mr Good News Feb 22 '18 at 13:45
  • @MrGoodNews Please see above edit - if we're specifying colour of each case individually in order, then we don't need to choose based on rownames. Just use `col = cols` – David Foster Feb 22 '18 at 13:50