aboutsummaryrefslogtreecommitdiff
path: root/R
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 /R
parent9ffec8b386646c51d1458f9c9c7b3124a8d9c91c (diff)
Some changes to improve plots on beamer slides
Diffstat (limited to 'R')
-rw-r--r--R/mkinerrplot.R3
-rw-r--r--R/plot.mkinfit.R9
-rw-r--r--R/plot.mmkin.R25
3 files changed, 22 insertions, 15 deletions
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)

Contact - Imprint