aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--R/plot.mmkin.R26
-rw-r--r--docs/reference/plot.mmkin.html8
-rw-r--r--man/plot.mmkin.Rd4
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." />
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">mkin</a>
- <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.6</span>
+ <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.8</span>
</span>
</div>
@@ -147,7 +147,7 @@ the fit of at least one model to the same dataset is shown.</p>
<span class='fu'><a href='https://rdrr.io/r/graphics/plot.html'>plot</a></span>(<span class='no'>x</span>, <span class='kw'>main</span> <span class='kw'>=</span> <span class='st'>"auto"</span>, <span class='kw'>legends</span> <span class='kw'>=</span> <span class='fl'>1</span>,
<span class='kw'>resplot</span> <span class='kw'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span>(<span class='st'>"time"</span>, <span class='st'>"errmod"</span>), <span class='kw'>show_errmin</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
<span class='kw'>errmin_var</span> <span class='kw'>=</span> <span class='st'>"All data"</span>, <span class='kw'>errmin_digits</span> <span class='kw'>=</span> <span class='fl'>3</span>, <span class='kw'>cex</span> <span class='kw'>=</span> <span class='fl'>0.7</span>,
- <span class='kw'>rel.height.middle</span> <span class='kw'>=</span> <span class='fl'>0.9</span>, <span class='no'>...</span>)</pre>
+ <span class='kw'>rel.height.middle</span> <span class='kw'>=</span> <span class='fl'>0.9</span>, <span class='kw'>ymax</span> <span class='kw'>=</span> <span class='st'>"auto"</span>, <span class='no'>...</span>)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments">
@@ -196,6 +196,10 @@ chi2 error percentage.</p></td>
than two rows of plots are shown.</p></td>
</tr>
<tr>
+ <th>ymax</th>
+ <td><p>Maximum y axis value for <code><a href='plot.mkinfit.html'>plot.mkinfit</a></code>.</p></td>
+ </tr>
+ <tr>
<th>...</th>
<td><p>Further arguments passed to <code><a href='plot.mkinfit.html'>plot.mkinfit</a></code> and
<code><a href='mkinresplot.html'>mkinresplot</a></code>.</p></td>
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}}.}
}

Contact - Imprint