From kleiweg at let.rug.nl  Wed Sep 17 02:30:58 2003
From: kleiweg at let.rug.nl (kleiweg@let.rug.nl)
Date: Wed Sep 17 01:33:43 2003
Subject: [Rd] plot.hclust: dendrogram too large for window (PR#4197)
Message-ID: <200309162330.h8GNUwJH024887@pubhealth.ku.dk>


plot.hclust:
Setting up a window for a dendrogram assumes the first link is
the shortest and the last is the longest. This is not always the
case when the clustering was done with hclust, method="median"
or method="centroid", and the dendrogram sometimes doesn't fit
within the window.

I propose the fix listed below.


src/main/

--- plot.c     Wed Sep 17 01:03:39 2003
+++ plot.c.new      Wed Sep 17 01:21:59 2003
@@ -3314,7 +3314,7 @@
 SEXP do_dendwindow(SEXP call, SEXP op, SEXP args, SEXP env)
 {
     int i, imax, n;
-    double pin, *ll, tmp, yval, *y, ymin, ymax, yrange;
+    double pin, *ll, tmp, yval, *y, ymin, ymax, yrange, m;
     SEXP originalArgs, merge, height, llabels, str;
     char *vmax;
     DevDesc *dd;
@@ -3357,8 +3357,14 @@
     ll =  (double*)R_alloc(n, sizeof(double));
     dnd_lptr = &(INTEGER(merge)[0]);
     dnd_rptr = &(INTEGER(merge)[n]);
-    ymin = REAL(height)[0];
-    ymax = REAL(height)[n - 1];
+    ymax = ymin = REAL(height)[0];
+    for (i = 1; i < n; i++) {
+      m = REAL(height)[i];
+      if (m > ymax)
+       ymax = m;
+      if (m < ymin)
+       ymin = m;
+    }
     pin = Rf_gpptr(dd)->pin[1];
     for (i = 0; i < n; i++) {
        str = STRING_ELT(llabels, i);




--please do not edit the information below--

Version:
 platform = i686-pc-linux-gnu
 arch = i686
 os = linux-gnu
 system = i686, linux-gnu
 status =
 major = 1
 minor = 7.1
 year = 2003
 month = 06
 day = 16
 language = R

Search Path:
 .GlobalEnv, package:methods, package:ctest, package:mva, package:modreg, package:nls, package:ts, Autoloads, package:base


[Rd] plot.hclust: dendrogram too large for window (PR#4197)
kleiweg@let.rug.nl