Hi Tobias and thank you for your reply,

Using your insight I managed to work-around the issue (with some help) by
increasing
the "mai" option of par().
For example a "mai" with first coordinate (bottom) set to 5 allows to
display ~ 42 letters.

We tried to change the xpd value in the text() call that you mentioned, but
it did not seem to fix the problem.

But I think this is very annoying: the dendrogram plot is meant to be the
common unique plotting for all clustering stuff
and suddenly if your labels are just too long, nothing get displayed,
without even a warning.
I suppose that the margins should be dynamically set based on the max label
text drawn length...

The hclust plot seemed to handle very nicely these long labels, but I need
to display colored labels and the only way I found is to use the
plot.dendrogram for this.

Best,

Karl

On Tue, Jan 25, 2011 at 12:17 PM, Tobias Verbeke <
tobias.verbeke@openanalytics.eu> wrote:

> Hi Karl,
>
>
> On 01/25/2011 11:27 AM, Karl Forner wrote:
>
>  It seems that the plot function for dendrograms does not draw labels when
>> they are too long.
>>
>>  hc<- hclust(dist(USArrests), "ave")
>>> dend1<- as.dendrogram(hc)
>>> dend2<- cut(dend1, h=70)
>>> dd<- dend2$lower[[1]]
>>> plot(dd) # first label is drawn
>>> attr(dd[[1]], "label")<- "aaaaaaaaaaaaaaaaaa"
>>> plot(dd) # first label is NOT drawn
>>>
>>
>> Is this expected ?
>>
>
> Reading the code of stats:::plotNode, yes.
>
> Clipping to the figure region is hard-coded.
>
> You can see it is clipping to the figure region as follows:
>
>
> hc <- hclust(dist(USArrests), "ave")
> dend1 <- as.dendrogram(hc)
> dend2 <- cut(dend1, h=70)
> dd <- dend2$lower[[1]]
> op <- par(oma = c(8,4,4,2)+0.1, xpd = NA)
>
> plot(dd) # first label is drawn
> attr(dd[[1]], "label") <- "abcdefghijklmnopqrstuvwxyz"
>
> plot(dd) # first label is NOT drawn
> box(which = "figure")
> par(op)
>
>
>  Is it possible to force the drawing ?
>>
>
> These are (from very quick reading -- not verified)
> the culprit lines in plotNode, I think:
>
> text(xBot, yBot + vln, nodeText, xpd = TRUE, # <- clipping hard-coded
>                  cex = lab.cex, col = lab.col, font = lab.font)
>
> Best,
> Tobias
>

	[[alternative HTML version deleted]]

