- Ntip <- .last_plot.phylo$Ntip
- d <- sqrt((xy$x - .last_plot.phylo$xx)^2 +
- (xy$y - .last_plot.phylo$yy)^2)
+ if (is.null(xy)) return(NULL)
+ lastPP <- get("last_plot.phylo", envir = .PlotPhyloEnv)
+ ## rescale the coordinates (especially if the x- and
+ ## y-scales are very different):
+ pin <- par("pin")
+ rescaleX <- pin[1]/max(lastPP$xx)
+ xx <- rescaleX * lastPP$xx
+ rescaleY <- pin[2]/max(lastPP$yy)
+ yy <- rescaleY * lastPP$yy
+ xy$x <- rescaleX * xy$x
+ xy$y <- rescaleY * xy$y
+ ## end of rescaling
+ d <- (xy$x - xx)^2 + (xy$y - yy)^2 # no need to sqrt()