aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.Rbuildignore1
-rw-r--r--DESCRIPTION2
-rw-r--r--NAMESPACE1
-rw-r--r--R/plot.mkinfit.R11
-rw-r--r--R/plot.mmkin.R12
-rw-r--r--man/plot.mkinfit.Rd4
-rw-r--r--man/plot.mmkin.Rd3
7 files changed, 29 insertions, 5 deletions
diff --git a/.Rbuildignore b/.Rbuildignore
index b037b763..c491eb32 100644
--- a/.Rbuildignore
+++ b/.Rbuildignore
@@ -9,6 +9,7 @@
^docs/*
^vignettes/.build.timestamp$
^vignettes/*_cache$
+^vignettes/*cache$
^vignettes/*_files$
^vignettes/*.aux$
^vignettes/*.bbl$
diff --git a/DESCRIPTION b/DESCRIPTION
index 1a29ec35..b3b0d22d 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -18,7 +18,7 @@ Description: Calculation routines based on the FOCUS Kinetics Report (2006,
purpose.
Depends: minpack.lm, rootSolve, inline, parallel
Imports: stats, graphics, methods, FME, deSolve, R6
-Suggests: knitr, testthat, microbenchmark, ggplot2
+Suggests: knitr, testthat, microbenchmark, ggplot2, tikzDevice
License: GPL
LazyLoad: yes
LazyData: yes
diff --git a/NAMESPACE b/NAMESPACE
index 3c71a845..458d5310 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -20,3 +20,4 @@ import(
importFrom(deSolve, ode)
importFrom(methods, signature)
importFrom(R6, R6Class)
+importFrom(grDevices, dev.cur)
diff --git a/R/plot.mkinfit.R b/R/plot.mkinfit.R
index 3df6c81c..b42ce097 100644
--- a/R/plot.mkinfit.R
+++ b/R/plot.mkinfit.R
@@ -172,8 +172,15 @@ plot.mkinfit <- function(x, fit = x,
}
}
- chi2 <- paste0(signif(100 * mkinerrmin(fit)[errmin_var, "err.min"], errmin_digits), "%")
- mtext(bquote(chi^2 ~ "error level" == .(chi2)), cex = 0.7, line = 0.4)
+ 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("$\\chi^2$ error level = ", chi2, "\\%")
+ } else {
+ chi2_perc <- paste0(chi2, "%")
+ chi2_text <- bquote(chi^2 ~ "error level" == .(chi2_perc))
+ }
+ mtext(chi2_text, cex = 0.7, line = 0.4)
}
# Show residuals if requested
diff --git a/R/plot.mmkin.R b/R/plot.mmkin.R
index 562bbb71..ee7075d3 100644
--- a/R/plot.mmkin.R
+++ b/R/plot.mmkin.R
@@ -79,8 +79,16 @@ plot.mmkin <- function(x, main = "auto", legends = 1, errmin_var = "All data", e
datasets = colnames(x)[i.fit],
none = "")
- chi2 <- paste0(signif(100 * mkinerrmin(fit)[errmin_var, "err.min"], errmin_digits), "%")
- mtext(bquote(.(fit_name) ~ chi^2 ~ "error level" == .(chi2)), cex = cex, line = 0.4)
+ 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)
mkinresplot(fit, legend = FALSE, ...)
mtext(paste(fit_name, "residuals"), cex = cex, line = 0.4)
diff --git a/man/plot.mkinfit.Rd b/man/plot.mkinfit.Rd
index a54bbbf6..42f2559c 100644
--- a/man/plot.mkinfit.Rd
+++ b/man/plot.mkinfit.Rd
@@ -8,6 +8,10 @@
Solves the differential equations with the optimised and fixed parameters
from a previous successful call to \code{\link{mkinfit}} and plots
the observed data together with the solution of the fitted model.
+
+ 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,
+ if \code{show_errmin = TRUE}.
}
\usage{
\method{plot}{mkinfit}(x, fit = x,
diff --git a/man/plot.mmkin.Rd b/man/plot.mmkin.Rd
index 7f3460d3..23f35c4b 100644
--- a/man/plot.mmkin.Rd
+++ b/man/plot.mmkin.Rd
@@ -7,6 +7,9 @@
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.
}
\usage{
\method{plot}{mmkin}(x, main = "auto", legends = 1, errmin_var = "All data", errmin_digits = 3,

Contact - Imprint