From 1868c1c6b98afa4c8a11b7c065d717bfb4ec1a8e Mon Sep 17 00:00:00 2001
From: Johannes Ranke
Date: Mon, 16 Dec 2019 02:51:19 +0100
Subject: Argument ymax for plot.mmkin
---
R/plot.mmkin.R | 26 ++++++++++++++++----------
docs/reference/plot.mmkin.html | 8 ++++++--
man/plot.mmkin.Rd | 4 +++-
3 files changed, 25 insertions(+), 13 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)
diff --git a/docs/reference/plot.mmkin.html b/docs/reference/plot.mmkin.html
index 8b68cfae..18907aa2 100644
--- a/docs/reference/plot.mmkin.html
+++ b/docs/reference/plot.mmkin.html
@@ -73,7 +73,7 @@ the fit of at least one model to the same dataset is shown." />
mkin
- 0.9.49.6
+ 0.9.49.8
@@ -147,7 +147,7 @@ the fit of at least one model to the same dataset is shown.
plot(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, ...)
+ rel.height.middle = 0.9, ymax = "auto", ...)
Arguments
@@ -195,6 +195,10 @@ chi2 error percentage.
The relative height of the middle plot, if more
than two rows of plots are shown. |
+
+ ymax |
+ Maximum y axis value for plot.mkinfit . |
+
... |
Further arguments passed to plot.mkinfit and
diff --git a/man/plot.mmkin.Rd b/man/plot.mmkin.Rd
index 333998da..605e458e 100644
--- a/man/plot.mmkin.Rd
+++ b/man/plot.mmkin.Rd
@@ -8,7 +8,7 @@ of an mmkin object}
\method{plot}{mmkin}(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, ...)
+ rel.height.middle = 0.9, ymax = "auto", ...)
}
\arguments{
\item{x}{An object of class \code{\link{mmkin}}, with either one row or one
@@ -36,6 +36,8 @@ chi2 error percentage.}
\item{rel.height.middle}{The relative height of the middle plot, if more
than two rows of plots are shown.}
+\item{ymax}{Maximum y axis value for \code{\link{plot.mkinfit}}.}
+
\item{\dots}{Further arguments passed to \code{\link{plot.mkinfit}} and
\code{\link{mkinresplot}}.}
}
--
cgit v1.2.1
|