diff options
| -rw-r--r-- | R/plot.mkinfit.R | 21 | ||||
| -rw-r--r-- | R/plot.mmkin.R | 18 | ||||
| -rw-r--r-- | man/mmkin.Rd | 15 | ||||
| -rw-r--r-- | man/plot.mkinfit.Rd | 2 | ||||
| -rw-r--r-- | man/plot.mmkin.Rd | 4 | 
5 files changed, 49 insertions, 11 deletions
| diff --git a/R/plot.mkinfit.R b/R/plot.mkinfit.R index 317c74a3..58ff88bc 100644 --- a/R/plot.mkinfit.R +++ b/R/plot.mkinfit.R @@ -103,6 +103,27 @@ plot.mkinfit <- function(x, fit = x,        ylim_row = ylim      } +    if (sep_obs) { +      # Margins for top row of plots when we have more than one row +      # Reduce bottom margin by 2.1 - hides x axis legend +      if (plot_row == 1 & n_plot_rows > 1) { +        par(mar = c(3.0, 4.1, 4.1, 2.1))  +      } + +      # Margins for middle rows of plots, if any +      if (plot_row > 1 & plot_row < n_plot_rows) { +        # Reduce top margin by 2 after the first plot as we have no main title,  +        # reduced plot height, therefore we need rel.height.middle in the layout +        par(mar = c(3.0, 4.1, 2.1, 2.1)) +      } + +      # Margins for bottom row of plots when we have more than one row +      if (plot_row == n_plot_rows & n_plot_rows > 1) { +        # Restore bottom margin for last plot to show x axis legend +        par(mar = c(5.1, 4.1, 2.1, 2.1)) +      } +    } +      # Set up the main plot if not to be added to an existing plot      if (add == FALSE) {        plot(0, type="n",  diff --git a/R/plot.mmkin.R b/R/plot.mmkin.R index 7b54be4b..2cbb4a79 100644 --- a/R/plot.mmkin.R +++ b/R/plot.mmkin.R @@ -46,15 +46,29 @@ plot.mmkin <- function(x, main = "auto", legends = 1, errmin_var = "All data", e                   else rep(1, n.fits)    layout(matrix(1:(2 * n.fits), n.fits, 2, byrow = TRUE), heights = rel.heights) -  par(mar = c(3.0, 4.1, 4.1, 2.1)) # Reduce bottom margin by 2.1 - hides x axis legend    par(cex = cex)    for (i.fit in 1:n.fits) { -    if (i.fit == 2) { + +    # Margins for top row of plots when we have more than one row +    # Reduce bottom margin by 2.1 - hides x axis legend +    if (i.fit == 1 & n.fits > 1) { +      par(mar = c(3.0, 4.1, 4.1, 2.1))  +    } + +    # Margins for middle rows of plots, if any +    if (i.fit > 1 & i.fit < n.fits) {        # Reduce top margin by 2 after the first plot as we have no main title,         # reduced plot height, therefore we need rel.height.middle in the layout        par(mar = c(3.0, 4.1, 2.1, 2.1))      } + +    # Margins for bottom row of plots when we have more than one row +    if (i.fit == n.fits & n.fits > 1) { +      # Restore bottom margin for last plot to show x axis legend +      par(mar = c(5.1, 4.1, 2.1, 2.1)) +    } +      fit <- x[[i.fit]]      plot(fit, legend = legends == i.fit, ...) diff --git a/man/mmkin.Rd b/man/mmkin.Rd index 44caf8d2..d088e804 100644 --- a/man/mmkin.Rd +++ b/man/mmkin.Rd @@ -45,16 +45,17 @@ mmkin(models, datasets,  }  \examples{  \dontrun{ -m_synth_SFO_lin <- mkinmod(parent = list(type = "SFO", to = "M1"), -                           M1 = list(type = "SFO", to = "M2"), -                           M2 = list(type = "SFO"), use_of_ff = "max") +m_synth_SFO_lin <- mkinmod(parent = mkinsub("SFO", "M1"), +                           M1 = mkinsub("SFO", "M2"), +                           M2 = mkinsub("SFO"), use_of_ff = "max") -m_synth_FOMC_lin <- mkinmod(parent = list(type = "FOMC", to = "M1"), -                           M1 = list(type = "SFO", to = "M2"), -                           M2 = list(type = "SFO"), use_of_ff = "max") +m_synth_FOMC_lin <- mkinmod(parent = mkinsub("FOMC", "M1"), +                            M1 = mkinsub("SFO", "M2"), +                            M2 = mkinsub("SFO"), use_of_ff = "max")  models <- list(SFO_lin = m_synth_SFO_lin, FOMC_lin = m_synth_FOMC_lin)  datasets <- lapply(synthetic_data_for_UBA_2014[1:3], function(x) x$data) +names(datasets) <- paste("Dataset", 1:3)  time_default <- system.time(fits.0 <- mmkin(models, datasets))  time_1 <- system.time(fits.1 <- mmkin(models, datasets, cores = 1)) @@ -66,9 +67,11 @@ endpoints(fits[["SFO_lin", 2]])  # Plot.mkinfit handles rows or columns of mmkin result objects  plot(fits.0[1, ]) +plot(fits.0[, 1])  # Double brackets to select a single mkinfit object, which will be  # plotted by plot.mkinfit  plot(fits.0[[1, 1]], sep_obs = TRUE, show_residuals = TRUE) +plot(fits.0[1, 1])  }  }  \keyword{ optimize } diff --git a/man/plot.mkinfit.Rd b/man/plot.mkinfit.Rd index 00b2eca5..bc0b85e8 100644 --- a/man/plot.mkinfit.Rd +++ b/man/plot.mkinfit.Rd @@ -18,7 +18,7 @@    lty_obs = rep(1, length(obs_vars)),    add = FALSE, legend = !add,    show_residuals = FALSE, maxabs = "auto", -  sep_vars = FALSE, rel.height.middle = 0.9, +  sep_obs = FALSE, rel.height.middle = 0.9,    lpos = "topright", inset = c(0.05, 0.05), \dots)  }  \arguments{ diff --git a/man/plot.mmkin.Rd b/man/plot.mmkin.Rd index ffd83d2f..37d7a25a 100644 --- a/man/plot.mmkin.Rd +++ b/man/plot.mmkin.Rd @@ -45,9 +45,9 @@    Johannes Ranke  }  \examples{ -  # Only use one core not to offend CRAN checks +  # Only use one core not to offend CRAN checks, use Levenberg-Marquardt for speed    fits <- mmkin(c("FOMC", "HS"), list("FOCUS B" = FOCUS_2006_B, "FOCUS C" = FOCUS_2006_C),  -                cores = 1, quiet = TRUE) +                cores = 1, quiet = TRUE, method.modFit = "Marq")    plot(fits[, "FOCUS C"])    plot(fits["FOMC", ]) | 
