aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2019-09-02 16:14:50 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2019-09-02 16:14:50 +0200
commitee99cf40fdf6d986a909010d18063ad032f69899 (patch)
treea122d1249db9b27a2bc45a06b4ed05a33b8fb9ba
parent9ffec8b386646c51d1458f9c9c7b3124a8d9c91c (diff)
Some changes to improve plots on beamer slides
-rw-r--r--DESCRIPTION2
-rw-r--r--NEWS.md6
-rw-r--r--R/mkinerrplot.R3
-rw-r--r--R/plot.mkinfit.R9
-rw-r--r--R/plot.mmkin.R25
-rw-r--r--man/mkinerrplot.Rd4
-rw-r--r--man/plot.mkinfit.Rd5
-rw-r--r--man/plot.mmkin.Rd7
8 files changed, 41 insertions, 20 deletions
diff --git a/DESCRIPTION b/DESCRIPTION
index b95c33bd..bc8e61d6 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -2,7 +2,7 @@ Package: mkin
Type: Package
Title: Kinetic Evaluation of Chemical Degradation Data
Version: 0.9.49.6
-Date: 2019-07-05
+Date: 2019-09-02
Authors@R: c(person("Johannes", "Ranke", role = c("aut", "cre", "cph"),
email = "jranke@uni-bremen.de",
comment = c(ORCID = "0000-0003-4371-6538")),
diff --git a/NEWS.md b/NEWS.md
index 949776ca..477247b5 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,4 +1,8 @@
-# mkin 0.9.49.6 (2019-07-08)
+# mkin 0.9.49.6 (unreleased)
+
+- Support frameless plots ('frame = FALSE')
+
+- Support to suppress the chi2 error level ('show_errmin = FALSE') in 'plot.mmkin'
- Update README and the introductory vignette
diff --git a/R/mkinerrplot.R b/R/mkinerrplot.R
index cc163922..6153a3c0 100644
--- a/R/mkinerrplot.R
+++ b/R/mkinerrplot.R
@@ -23,6 +23,7 @@ mkinerrplot <- function (object,
xlab = "Predicted", ylab = "Squared residual",
maxy = "auto", legend= TRUE, lpos = "topright",
col_obs = "auto", pch_obs = "auto",
+ frame = TRUE,
...)
{
obs_vars_all <- as.character(unique(object$data$variable))
@@ -48,7 +49,7 @@ mkinerrplot <- function (object,
plot(0, type = "n",
xlab = xlab, ylab = ylab,
xlim = xlim,
- ylim = c(0, 1.2 * maxy), ...)
+ ylim = c(0, 1.2 * maxy), frame = frame, ...)
for(obs_var in obs_vars){
residuals_plot <- subset(object$data, variable == obs_var, c("predicted", "residual"))
diff --git a/R/plot.mkinfit.R b/R/plot.mkinfit.R
index df9888e7..2a82301f 100644
--- a/R/plot.mkinfit.R
+++ b/R/plot.mkinfit.R
@@ -31,7 +31,8 @@ plot.mkinfit <- function(x, fit = x,
maxabs = "auto",
sep_obs = FALSE, rel.height.middle = 0.9,
lpos = "topright", inset = c(0.05, 0.05),
- show_errmin = FALSE, errmin_digits = 3, ...)
+ show_errmin = FALSE, errmin_digits = 3,
+ frame = TRUE, ...)
{
if (add && show_residuals) stop("If adding to an existing plot we can not show residuals")
if (add && show_errplot) stop("If adding to an existing plot we can not show the error model plot")
@@ -138,7 +139,7 @@ plot.mkinfit <- function(x, fit = x,
if (add == FALSE) {
plot(0, type="n",
xlim = xlim, ylim = ylim_row,
- xlab = xlab, ylab = ylab, ...)
+ xlab = xlab, ylab = ylab, frame = frame, ...)
}
# Plot the data
@@ -197,7 +198,7 @@ plot.mkinfit <- function(x, fit = x,
plot(0, type="n",
xlim = xlim,
ylim = c(-1.2 * maxabs_row, 1.2 * maxabs_row),
- xlab = xlab, ylab = "Residuals")
+ xlab = xlab, ylab = "Residuals", frame = frame)
for(obs_var in row_obs_vars){
residuals_plot <- subset(fit$data, variable == obs_var, c("time", "residual"))
points(residuals_plot, pch = pch_obs[obs_var], col = col_obs[obs_var])
@@ -208,7 +209,7 @@ plot.mkinfit <- function(x, fit = x,
# Show error model plot if requested
if (show_errplot) {
mkinerrplot(fit, obs_vars = row_obs_vars, pch_obs = pch_obs[row_obs_vars], col_obs = col_obs[row_obs_vars],
- legend = FALSE)
+ legend = FALSE, frame = frame)
}
}
if (do_layout) par(oldpar, no.readonly = TRUE)
diff --git a/R/plot.mmkin.R b/R/plot.mmkin.R
index c9d98718..ef80949c 100644
--- a/R/plot.mmkin.R
+++ b/R/plot.mmkin.R
@@ -18,6 +18,7 @@
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, ...) {
n.m <- nrow(x)
@@ -83,23 +84,27 @@ plot.mmkin <- function(x, main = "auto", legends = 1,
datasets = colnames(x)[i.fit],
none = "")
- chi2 <- signif(100 * mkinerrmin(fit)[errmin_var, "err.min"], errmin_digits)
-
- # Use LateX if the current plotting device is tikz
- if (names(dev.cur()) == "tikz output") {
- chi2_text <- paste0(fit_name, " $\\chi^2$ error level = ", chi2, "\\%")
- } else {
- chi2_perc <- paste0(chi2, "%")
- chi2_text <- bquote(.(fit_name) ~ chi^2 ~ "error level" == .(chi2_perc))
+ if (show_errmin) {
+ chi2 <- signif(100 * mkinerrmin(fit)[errmin_var, "err.min"], errmin_digits)
+
+ # Use LateX if the current plotting device is tikz
+ if (names(dev.cur()) == "tikz output") {
+ chi2_text <- paste0(fit_name, " $\\chi^2$ error level = ", chi2, "\\%")
+ } else {
+ chi2_perc <- paste0(chi2, "%")
+ chi2_text <- bquote(.(fit_name) ~ chi^2 ~ "error level" == .(chi2_perc))
+ }
+ mtext(chi2_text, cex = cex, line = 0.4)
}
- mtext(chi2_text, cex = cex, line = 0.4)
if (resplot == "time") {
mkinresplot(fit, legend = FALSE, ...)
} else {
mkinerrplot(fit, legend = FALSE, ...)
}
- mtext(paste(fit_name, "residuals"), cex = cex, line = 0.4)
+ if (show_errmin) {
+ mtext(paste(fit_name, "residuals"), cex = cex, line = 0.4)
+ }
}
par(oldpar, no.readonly = TRUE)
diff --git a/man/mkinerrplot.Rd b/man/mkinerrplot.Rd
index 3b557b0a..37338d01 100644
--- a/man/mkinerrplot.Rd
+++ b/man/mkinerrplot.Rd
@@ -18,6 +18,7 @@
xlab = "Predicted", ylab = "Squared residual",
maxy = "auto", legend= TRUE, lpos = "topright",
col_obs = "auto", pch_obs = "auto",
+ frame = TRUE,
...)
}
\arguments{
@@ -54,6 +55,9 @@
\item{pch_obs}{
Symbols to be used for the observed variables.
}
+ \item{frame}{
+ Should a frame be drawn around the plots?
+ }
\item{\dots}{
further arguments passed to \code{\link{plot}}.
}
diff --git a/man/plot.mkinfit.Rd b/man/plot.mkinfit.Rd
index 5e20ad90..a4f47073 100644
--- a/man/plot.mkinfit.Rd
+++ b/man/plot.mkinfit.Rd
@@ -27,7 +27,7 @@
maxabs = "auto",
sep_obs = FALSE, rel.height.middle = 0.9,
lpos = "topright", inset = c(0.05, 0.05),
- show_errmin = FALSE, errmin_digits = 3, \dots)
+ show_errmin = FALSE, errmin_digits = 3, frame = TRUE, \dots)
plot_sep(fit, sep_obs = TRUE, show_residuals = TRUE, show_errmin = TRUE, \dots)
}
\arguments{
@@ -105,6 +105,9 @@ plot_sep(fit, sep_obs = TRUE, show_residuals = TRUE, show_errmin = TRUE, \dots)
\item{errmin_digits}{
The number of significant digits for rounding the FOCUS chi2 error percentage.
}
+ \item{frame}{
+ Should a frame be drawn around the plots?
+ }
\item{\dots}{
Further arguments passed to \code{\link{plot}}.
}
diff --git a/man/plot.mmkin.Rd b/man/plot.mmkin.Rd
index 44e5e4c7..90b92d27 100644
--- a/man/plot.mmkin.Rd
+++ b/man/plot.mmkin.Rd
@@ -13,8 +13,8 @@
}
\usage{
\method{plot}{mmkin}(x, main = "auto", legends = 1,
- resplot = c("time", "errmod"), errmin_var = "All data", errmin_digits = 3,
- cex = 0.7, rel.height.middle = 0.9, ...)
+ resplot = c("time", "errmod"), show_errmin = TRUE, errmin_var = "All data",
+ errmin_digits = 3, cex = 0.7, rel.height.middle = 0.9, ...)
}
\arguments{
\item{x}{
@@ -31,6 +31,9 @@
or as squared residuals against predicted values, with the error model,
using \code{\link{mkinerrplot}}.
}
+ \item{show_errmin}{
+ Should the chi2 error level be shown on top of the plots to the left?
+ }
\item{errmin_var}{
The variable for which the FOCUS chi2 error value should be shown.
}

Contact - Imprint