[R] plotting hclust dendrograms

Schulze, Diana dschulze at ipb-halle.de
Mon Mar 10 10:25:30 CET 2008


Hallo everybody,

I have a question concerning plotting of hclust dendrograms.

I created several of those dendrograms and like to plot them in different
plots. I'd like to have all plots with the same scaling of the y axis so that
they become comparable by eye. That means they should all start at y=0 and
end up with a certain given value, e.g. y=8. I tried the following:

	plot(
		hclust_object,
		main = "Single Linkage Clustering for Outlier Detection",
		sub  = "",
		axes = FALSE, # y axis is separately drawn by axis
		hang = -1, 	  # all leafs start at y=0
	)
	lines(x = c(0,0), y = c(0,8), type = "n") # force extension of y axis
	axis(
		side	 = 2,
		at	 = seq(0,8,0.5), # at which values of the plot shall
ticks be drawn?
		labels = seq(0,8,0.5),
	)

But this does not work: the line drawn is simply cutted at the upper end of
the hclust-plot. So what I'm searching for is, I think, a possibility to add
the hclust dendrogram to an existing plot. So this would allow me to swap the
two command plot and lines, so that the extend of the y axis would be given
by the plotting of lines.

Can anyone help me with this?
Thank you very much in advance!

Diana



More information about the R-help mailing list