Skip to content

plot.dendrogram xlim/ylim

2 messages · Felix Andrews, Martin Maechler

#
list(...),

I would like to zoom in to the leaves of large trees in a dendrogram
plot. The playwith package allows zooming by passing xlim and ylim
arguments to the plot call (Hmisc does this too I think). But
currently stats:::plot.dendrogram does not accept xlim or ylim. So I
would like to enable that. In place of the existing code chunk:

    xlim <- c(x1 - 1/2, x2 + 1/2)
    ylim <- c(0, yTop)
    if (horiz) {
        xl <- xlim
        xlim <- rev(ylim)
        ylim <- xl
        tmp <- xaxt
        xaxt <- yaxt
        yaxt <- tmp
    }
    plot(0, xlim = xlim, ylim = ylim, ......

I propose something like:

function(..., xlim, ylim)

    xlim0 <- c(x1 - 1/2, x2 + 1/2)
    ylim0 <- c(0, yTop)
    if (horiz) {
        xl <- xlim0
        xlim0 <- rev(ylim0)
        ylim <- xl
        tmp <- xaxt
        xaxt <- yaxt
        yaxt <- tmp
    }
    if (missing(xlim)) xlim <- xlim0
    if (missing(ylim)) ylim <- ylim0
    plot(0, xlim = xlim, ylim = ylim, ......


Regards,
Felix
#
FA> list(...), I would like to zoom in to the leaves of
    FA> large trees in a dendrogram plot. The playwith package
    FA> allows zooming by passing xlim and ylim arguments to the
    FA> plot call (Hmisc does this too I think). But currently
    FA> stats:::plot.dendrogram does not accept xlim or ylim. So
    FA> I would like to enable that. In place of the existing
    FA> code chunk:

  >>     xlim <- c(x1 - 1/2, x2 + 1/2)
  >>     ylim <- c(0, yTop)
  >>     if (horiz) {
  >>         xl <- xlim
  >>         xlim <- rev(ylim)
  >>         ylim <- xl
  >>         tmp <- xaxt
  >>         xaxt <- yaxt
  >>         yaxt <- tmp
  >>     }
  >>     plot(0, xlim = xlim, ylim = ylim, ......
  >> 
  >> I propose something like:
  >> 
  >> function(..., xlim, ylim)
  >> 
  >>     xlim0 <- c(x1 - 1/2, x2 + 1/2)
  >>     ylim0 <- c(0, yTop)
  >>     if (horiz) {
  >>         xl <- xlim0
  >>         xlim0 <- rev(ylim0)
  >>         ylim <- xl
  >>         tmp <- xaxt
  >>         xaxt <- yaxt
  >>         yaxt <- tmp
  >>     }
  >>     if (missing(xlim)) xlim <- xlim0
  >>     if (missing(ylim)) ylim <- ylim0
  >>     plot(0, xlim = xlim, ylim = ylim, ......

Thank you for the suggestion!
Yes, "something like" this will be part of R 2.8.0
(or 'R-devel' as from tomorrow).

Martin Maechler, ETH Zurich