diff options
Diffstat (limited to 'R')
-rw-r--r-- | R/plot.mmkin.R | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/R/plot.mmkin.R b/R/plot.mmkin.R index eefafe12..182e74ca 100644 --- a/R/plot.mmkin.R +++ b/R/plot.mmkin.R @@ -1,13 +1,13 @@ #' Plot model fits (observed and fitted) and the residuals for a row or column #' of an mmkin object -#' +#' #' When x is a row selected from an mmkin object (\code{\link{[.mmkin}}), the #' same model fitted for at least one dataset is shown. When it is a column, #' the fit of at least one model to the same dataset is shown. -#' +#' #' If the current plot device is a \code{\link[tikzDevice]{tikz}} device, then #' latex is being used for the formatting of the chi2 error level. -#' +#' #' @param x An object of class \code{\link{mmkin}}, with either one row or one #' column. #' @param main The main title placed on the outer margin of the plot. @@ -24,12 +24,13 @@ #' @param cex Passed to the plot functions and \code{\link{mtext}}. #' @param rel.height.middle The relative height of the middle plot, if more #' than two rows of plots are shown. +#' @param ymax Maximum y axis value for \code{\link{plot.mkinfit}}. #' @param \dots Further arguments passed to \code{\link{plot.mkinfit}} and #' \code{\link{mkinresplot}}. #' @return The function is called for its side effect. #' @author Johannes Ranke #' @examples -#' +#' #' \dontrun{ #' # Only use one core not to offend CRAN checks #' fits <- mmkin(c("FOMC", "HS"), @@ -37,22 +38,23 @@ #' cores = 1, quiet = TRUE, error_model = "tc") #' plot(fits[, "FOCUS C"]) #' plot(fits["FOMC", ]) -#' +#' #' # We can also plot a single fit, if we like the way plot.mmkin works, but then the plot #' # height should be smaller than the plot width (this is not possible for the html pages #' # generated by pkgdown, as far as I know). #' plot(fits["FOMC", "FOCUS C"]) # same as plot(fits[1, 2]) -#' +#' #' # Show the error models #' plot(fits["FOMC", ], resplot = "errmod") #' } -#' +#' #' @export -plot.mmkin <- function(x, main = "auto", legends = 1, +plot.mmkin <- function(x, main = "auto", legends = 1, resplot = c("time", "errmod"), show_errmin = TRUE, errmin_var = "All data", errmin_digits = 3, - cex = 0.7, rel.height.middle = 0.9, ...) { + cex = 0.7, rel.height.middle = 0.9, + ymax = "auto", ...) { n.m <- nrow(x) n.d <- ncol(x) @@ -107,7 +109,11 @@ plot.mmkin <- function(x, main = "auto", legends = 1, } fit <- x[[i.fit]] - plot(fit, legend = legends == i.fit, ...) + if (ymax == "auto") { + plot(fit, legend = legends == i.fit, ...) + } else { + plot(fit, legend = legends == i.fit, ylim = c(0, ymax), ...) + } title(main, outer = TRUE, line = -2) |