From e6ba7af29db678ef437e7f8301299ec18f4c66a4 Mon Sep 17 00:00:00 2001 From: jranke Date: Tue, 5 Feb 2013 05:03:20 +0000 Subject: - Prevent wrong association of colors and linetypes in plots during mkinfit operation - Make solid lines the default in such plots, as in plot.mkinfit git-svn-id: svn+ssh://svn.r-forge.r-project.org/svnroot/kinfit/pkg/mkin@60 edb9625f-4e0d-4859-8d74-9fd3b1da38cb --- R/mkinfit.R | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'R') diff --git a/R/mkinfit.R b/R/mkinfit.R index 3649b20..f574b6e 100644 --- a/R/mkinfit.R +++ b/R/mkinfit.R @@ -36,11 +36,11 @@ mkinfit <- function(mkinmod, observed, # Get the names of the state variables in the model mod_vars <- names(mkinmod$diffs) - # Subset observed data with names of observed data in the model - observed <- subset(observed, name %in% names(mkinmod$map)) + # Get the names of observed variables + obs_vars = names(mkinmod$map) - # Get names of observed variables - obs_vars = unique(as.character(observed$name)) + # Subset observed data with names of observed data in the model + observed <- subset(observed, name %in% obs_vars) # Define starting values for parameters where not specified by the user if (parms.ini[[1]] == "auto") parms.ini = vector() @@ -152,12 +152,13 @@ mkinfit <- function(mkinmod, observed, xlim = range(observed$time), ylim = range(observed$value, na.rm=TRUE), xlab = "Time", ylab = "Observed") col_obs <- pch_obs <- 1:length(obs_vars) - names(col_obs) <- names(pch_obs) <- obs_vars + lty_obs <- rep(1, length(obs_vars)) + names(col_obs) <- names(pch_obs) <- names(lty_obs) <- obs_vars for (obs_var in obs_vars) { points(subset(observed, name == obs_var, c(time, value)), pch = pch_obs[obs_var], col = col_obs[obs_var]) } - matlines(out_plot$time, out_plot[-1]) + matlines(out_plot$time, out_plot[-1], co = col_obs, lty = lty_obs) legend("topright", inset=c(0.05, 0.05), legend=obs_vars, col=col_obs, pch=pch_obs, lty=1:length(pch_obs)) } -- cgit v1.2.1