aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorjranke <jranke@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>2013-02-05 05:03:20 +0000
committerjranke <jranke@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>2013-02-05 05:03:20 +0000
commite6ba7af29db678ef437e7f8301299ec18f4c66a4 (patch)
tree4f1d67bc490336b3b4bdd68231fe70e7917be20d /R
parentd10f5ee98dc5913e7ac581f06d1d9297d7ae7582 (diff)
- 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
Diffstat (limited to 'R')
-rw-r--r--R/mkinfit.R13
1 files changed, 7 insertions, 6 deletions
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))
}

Contact - Imprint