aboutsummaryrefslogtreecommitdiff
path: root/R/plot.mkinfit.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2016-06-25 19:36:16 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2016-06-25 19:36:16 +0200
commit693beea972cad4633c1d8baf422913ff3e8d709d (patch)
treec0ff57be6b9200e1984782e062e2a979db09c872 /R/plot.mkinfit.R
parente8392a8e110bb1957adc9e2047642f9387ff83db (diff)
Now the old behaviour is restored for compatibility reasons
When observed variables are not shown in separate plots, the residual plot is shown in the lower third of the total plotting area
Diffstat (limited to 'R/plot.mkinfit.R')
-rw-r--r--R/plot.mkinfit.R27
1 files changed, 17 insertions, 10 deletions
diff --git a/R/plot.mkinfit.R b/R/plot.mkinfit.R
index 6bc64351..317c74a3 100644
--- a/R/plot.mkinfit.R
+++ b/R/plot.mkinfit.R
@@ -68,16 +68,22 @@ plot.mkinfit <- function(x, fit = x,
# Layout should be restored afterwards
oldpar <- par(no.readonly = TRUE)
- n_plot_cols = if (show_residuals) 2 else 1
- n_plots = n_plot_rows * n_plot_cols
-
- # Set relative plot heights, so the first and the last plot are the norm
- # and the middle plots (if n_plot_rows >2) are smaller by rel.height.middle
- rel.heights <- if (n_plot_rows > 2) c(1, rep(rel.height.middle, n_plot_rows - 2), 1)
- else rep(1, n_plot_rows)
- layout_matrix = matrix(1:n_plots,
- n_plot_rows, n_plot_cols, byrow = TRUE)
- layout(layout_matrix, heights = rel.heights)
+ # If the observed variables are shown separately, do row layout
+ if (sep_obs) {
+ n_plot_cols = if (show_residuals) 2 else 1
+ n_plots = n_plot_rows * n_plot_cols
+
+ # Set relative plot heights, so the first and the last plot are the norm
+ # and the middle plots (if n_plot_rows >2) are smaller by rel.height.middle
+ rel.heights <- if (n_plot_rows > 2) c(1, rep(rel.height.middle, n_plot_rows - 2), 1)
+ else rep(1, n_plot_rows)
+ layout_matrix = matrix(1:n_plots,
+ n_plot_rows, n_plot_cols, byrow = TRUE)
+ layout(layout_matrix, heights = rel.heights)
+ } else { # else show residuals in the lower third to keep compatibility
+ layout(matrix(c(1, 2), 2, 1), heights = c(2, 1.3))
+ par(mar = c(3, 4, 4, 2) + 0.1)
+ }
}
# Replicate legend position argument if necessary
@@ -129,6 +135,7 @@ plot.mkinfit <- function(x, fit = x,
if (show_residuals) {
residuals <- subset(fit$data, variable %in% row_obs_vars, residual)
if (maxabs == "auto") maxabs = max(abs(residuals), na.rm = TRUE)
+ if (!sep_obs) par(mar = c(5, 4, 0, 2) + 0.1)
plot(0, type="n",
xlim = xlim,
ylim = c(-1.2 * maxabs, 1.2 * maxabs),

Contact - Imprint