diff --git a/R/miscfun.R b/R/miscfun.R index 3b05b45..d45ef28 100644 --- a/R/miscfun.R +++ b/R/miscfun.R @@ -33,12 +33,14 @@ nsgaMonitor <- function(object, number_objectives, ...) { "Iter: ", iter), xlim = range(fitness[, 1]), ylim = range(fitness[, 2]), xlab = "f_1", ylab = "f_2") - lines(first_front[, 1][order(first_front[, 1])], - first_front[, 2][order(first_front[, 1])], - xlim = range(first_front[, 1]), - ylim = range(first_front[, 2]), - xlab = "f_1", ylab = "f_2", - col = "red", type = "l", pch = 12, main = "Pareto Front") + if(!is.null(nrow(first_front)) && nrow(first_front) > 1) { + lines(first_front[, 1][order(first_front[, 1])], + first_front[, 2][order(first_front[, 1])], + xlim = range(first_front[, 1]), + ylim = range(first_front[, 2]), + xlab = "f_1", ylab = "f_2", + col = "red", type = "l", pch = 12, main = "Pareto Front") + } legend("topright", inset = c(-0.8, 0), legend = c("Population", "Pareto Optimal"), pch = c(19, NA), title = "Values", lwd = c(NA, 2),