Entering edit mode
mictadlo
▴
10
@mictadlo-10885
Last seen 5.8 years ago
How is it possible to get a legend outside plotMDS?
pch <- c(0,1,2,15,16,17)
colors <- rep(c("darkgreen", "red", "blue"), 2)
plotMDS(y, col=colors[group], pch=pch[group])
legend("topleft", legend=levels(group), pch=pch, col=colors, ncol=2)
Thank you in advance.

Or alternatively, if you are a fan of the tidyverse,
mds <- plotMDS(x) toplot <- data.frame(Dim1 = mds$x, Dim2 = mds$y, Group = factor(paste0("Grp", rep(1:2, each = 3)))) library(ggplot2) ggplot(toplot, aes(Dim1, Dim2, colour = Group)) + geom_point()