Reputation: 2183
Is there an equivalent of MATLAB's 'hold on' in R? I tried plotting a heatmap and then a dendrogram, but the display of the second figure removes the one of the first. I tried using par(mfrow)
but it doesn't change the outcome.
Code sample:
hc <- hclust(dist_(as.matrix(data)), method="complete")
plot(as.dendrogram(hc),horiz=T,new=TRUE)
heatmap(as.matrix(data), col=heat.colors(length(br)), hclust = hcl_, dist=d_,
breaks=c(br[1],br), scale="none", Rowv=Rowv, Colv=Colv)
Upvotes: 2
Views: 10194
Reputation: 21532
WHen I run the following code (note that I'm guessing your dist_
was a typo),
foo<- matrix(runif(400),20)
hc <- hclust(dist(foo), method="complete")
plot(as.dendrogram(hc),horiz=T)
par(new=TRUE)
heatmap(as.matrix(foo), col=heat.colors(10))
I get both plots, albeit with the heatmap (and its builtin dendrogram) badly squished to the left. Presumably that can be fixed with some attention to specifying x-axis limits.
Upvotes: 3