diff options
| -rw-r--r-- | R/plot.gensvm.R | 22 | ||||
| -rw-r--r-- | man/plot.gensvm.Rd | 10 |
2 files changed, 24 insertions, 8 deletions
diff --git a/R/plot.gensvm.R b/R/plot.gensvm.R index 85ff3b5..cbad9f0 100644 --- a/R/plot.gensvm.R +++ b/R/plot.gensvm.R @@ -15,6 +15,11 @@ #' @param with.legend show the legend for the class labels #' @param center.plot ensure that the boundaries and margins are always visible #' in the plot +#' @param xlim allows the user to force certain plot limits. If set, these +#' bounds will be used for the horizontal axis. +#' @param ylim allows the user to force certain plot limits. If set, these +#' bounds will be used for the vertical axis and the value of center.plot will +#' be ignored #' @param ... further arguments are ignored #' #' @return returns the object passed as input @@ -52,7 +57,7 @@ #' plot.gensvm <- function(fit, x, y.true=NULL, with.margins=TRUE, with.shading=TRUE, with.legend=TRUE, center.plot=TRUE, - ...) + xlim=NULL, ylim=NULL, ...) { if (fit$n.classes != 3) { cat("Error: Can only plot with 3 classes\n") @@ -74,7 +79,8 @@ plot.gensvm <- function(fit, x, y.true=NULL, with.margins=TRUE, return } if (!is.null(x.train) && ncol(x.train) != fit$n.features) { - cat("Error: Number of features of fitted model and training data disagree.") + cat("Error: Number of features of fitted model and training data ", + "disagree.\n", sep="") return } @@ -136,13 +142,15 @@ plot.gensvm <- function(fit, x, y.true=NULL, with.margins=TRUE, par(pty="s") if (center.plot) { - new.xlim <- c(min(min(S[, 1]), -1.2), max(max(S[, 1]), 1.2)) - new.ylim <- c(min(min(S[, 2]), -0.75), max(max(S[, 2]), 1.2)) + if (is.null(xlim)) + xlim <- c(min(min(S[, 1]), -1.2), max(max(S[, 1]), 1.2)) + if (is.null(ylim)) + ylim <- c(min(min(S[, 2]), -0.75), max(max(S[, 2]), 1.2)) plot(S[, 1], S[, 2], col=col.vector, pch=mark.vector, ylab='', xlab='', - asp=1, xlim=new.xlim, ylim=new.ylim) + asp=1, xlim=xlim, ylim=ylim) } else { - plot(S[, 1], S[, 2], col=col.vector, pch=mark.vector, ylab='', xlab='', - asp=1) + plot(S[, 1], S[, 2], col=col.vector, pch=mark.vector, ylab='', + xlab='', asp=1, xlim=xlim, ylim=ylim) } limits <- par("usr") diff --git a/man/plot.gensvm.Rd b/man/plot.gensvm.Rd index e28a108..243f687 100644 --- a/man/plot.gensvm.Rd +++ b/man/plot.gensvm.Rd @@ -5,7 +5,8 @@ \title{Plot the simplex space of the fitted GenSVM model} \usage{ \method{plot}{gensvm}(fit, x, y.true = NULL, with.margins = TRUE, - with.shading = TRUE, with.legend = TRUE, center.plot = TRUE, ...) + with.shading = TRUE, with.legend = TRUE, center.plot = TRUE, + xlim = NULL, ylim = NULL, ...) } \arguments{ \item{fit}{A fitted \code{gensvm} object} @@ -25,6 +26,13 @@ identify misclassified objects.} \item{center.plot}{ensure that the boundaries and margins are always visible in the plot} +\item{xlim}{allows the user to force certain plot limits. If set, these +bounds will be used for the horizontal axis.} + +\item{ylim}{allows the user to force certain plot limits. If set, these +bounds will be used for the vertical axis and the value of center.plot will +be ignored} + \item{...}{further arguments are ignored} } \value{ |
