diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2019-12-16 02:51:19 +0100 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2019-12-16 02:51:19 +0100 |
commit | 1868c1c6b98afa4c8a11b7c065d717bfb4ec1a8e (patch) | |
tree | 2ba5e6ccf93c6ebfb501f24fd0a73a893d53b9e4 /R/plot.mmkin.R | |
parent | 7c8e06d4bae9ec80574147005b7e933937447220 (diff) |
Argument ymax for plot.mmkin
Diffstat (limited to 'R/plot.mmkin.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) |