kleiweg@let.rug.nl
2003-Sep-17 01:33 UTC
[Rd] plot.hclust: dendrogram too large for window (PR#4197)
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
maechler@stat.math.ethz.ch
2003-Sep-30 18:03 UTC
[Rd] plot.hclust: dendrogram too large for window (PR#4197)
Thank you, Peter,>>>>> "Peter" == Peter Kleiweg <kleiweg@let.rug.nl> >>>>> on Wed, 17 Sep 2003 01:30:58 +0200 (MET DST) writes:Peter> plot.hclust: Peter> Setting up a window for a dendrogram assumes the first link is Peter> the shortest and the last is the longest. This is not always the Peter> case when the clustering was done with hclust, method="median" Peter> or method="centroid", and the dendrogram sometimes doesn't fit Peter> within the window. Peter> I propose the fix listed below. I'm about to apply this fix to "R 1.8.0 beta". Can you please __quickly__ give a reproducible *example* for which this bug applies, i.e., for which the fix will make a difference? Thanks in advance: Martin Maechler <maechler@stat.math.ethz.ch> http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 <>< Peter> src/main/ Peter> --- plot.c Wed Sep 17 01:03:39 2003 Peter> +++ plot.c.new Wed Sep 17 01:21:59 2003 Peter> @@ -3314,7 +3314,7 @@ Peter> SEXP do_dendwindow(SEXP call, SEXP op, SEXP args, SEXP env) Peter> { Peter> int i, imax, n; Peter> - double pin, *ll, tmp, yval, *y, ymin, ymax, yrange; Peter> + double pin, *ll, tmp, yval, *y, ymin, ymax, yrange, m; Peter> SEXP originalArgs, merge, height, llabels, str; Peter> char *vmax; Peter> DevDesc *dd; Peter> @@ -3357,8 +3357,14 @@ Peter> ll = (double*)R_alloc(n, sizeof(double)); Peter> dnd_lptr = &(INTEGER(merge)[0]); Peter> dnd_rptr = &(INTEGER(merge)[n]); Peter> - ymin = REAL(height)[0]; Peter> - ymax = REAL(height)[n - 1]; Peter> + ymax = ymin = REAL(height)[0]; Peter> + for (i = 1; i < n; i++) { Peter> + m = REAL(height)[i]; Peter> + if (m > ymax) Peter> + ymax = m; Peter> + if (m < ymin) Peter> + ymin = m; Peter> + } Peter> pin = Rf_gpptr(dd)->pin[1]; Peter> for (i = 0; i < n; i++) { Peter> str = STRING_ELT(llabels, i); Peter> --please do not edit the information below-- Peter> Version: Peter> platform = i686-pc-linux-gnu Peter> arch = i686 Peter> os = linux-gnu Peter> system = i686, linux-gnu Peter> status Peter> major = 1 Peter> minor = 7.1 Peter> year = 2003 Peter> month = 06 Peter> day = 16 Peter> language = R Peter> Search Path: Peter> .GlobalEnv, package:methods, package:ctest, package:mva, package:modreg, package:nls, package:ts, Autoloads, package:base