From 693beea972cad4633c1d8baf422913ff3e8d709d Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Sat, 25 Jun 2016 19:36:16 +0200 Subject: 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 --- R/plot.mkinfit.R | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'R') 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), -- cgit v1.2.1