diff --git a/R/ordiplot.R b/R/ordiplot.R index 36aaf457b..0bdc4b4a4 100644 --- a/R/ordiplot.R +++ b/R/ordiplot.R @@ -64,10 +64,22 @@ localPoints(Y, pch = "+", col = "red", cex = cex, ...) } if (type == "text") { - if (!is.null(X)) - localText(X, labels = rownames(X), col = 1, cex = cex, ...) - if (!is.null(Y)) - localText(Y, labels = rownames(Y), col = "red", cex = cex, ...) + if (!is.null(X)) { + labs <- rownames(X) + if (is.null(labs)) { + warning("type='t', but no names available: using x1...") + labs <- paste0("x", as.character(seq_len(nrow(X)))) + } + localText(X, labels = labs, col = 1, cex = cex, ...) + } + if (!is.null(Y)) { + labs <- rownames(Y) + if (is.null(labs)) { + warning("type='t', but no names available: using y1...") + labs <- paste0("y", as.character(seq_len(nrow(Y)))) + } + localText(Y, labels = labs, col = "red", cex = cex, ...) + } } out <- list(sites = X, species = Y) } diff --git a/R/print.wcmdscale.R b/R/print.wcmdscale.R index 63b368ccf..84de2ab21 100644 --- a/R/print.wcmdscale.R +++ b/R/print.wcmdscale.R @@ -55,6 +55,8 @@ choices <- choices[choices <= NCOL(x$points)] x$points[, choices, drop = FALSE] } + if (is.null(rownames(p))) + rownames(p) <- as.character(seq_len(nrow(p))) if (tidy) { p <- data.frame(p, "scores" = "sites", "label" = rownames(p), "weight" = weights(x))