A follow up question to my previous开发者_高级运维 one. R Colored dendrogram suggestions?
I'm usine the A2R library, http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=79 By default it limits the string length of the labels to six characters, I am trying to figure out how to allow for longer strings in the labels, as my labels are much longer. Reading the library currently, any thoughts? Also trying to figure out how to change font size as well.At the moment the 6 character limit is hard coded into that function. You need to hack it and the place to do so is in this section:
if (show.labels) {
par(mar = c(0, 0, 0, 4))
par(srt = 90)
obs.labels <- toupper(substr(x$labels[x$order], 1, 6))
if (is.null(members)) {
plot(0, type = "n", xlim = c(0.5, n.indiv + 0.5),
ylim = c(0, 1), xaxs = "i", axes = FALSE, xlab = "",
ylab = "")
text(1:n.indiv, 0, obs.labels, pos = 4, col = col.down[groups.o])
}
As you make the labels longer, you will need to either shrink the text inside the labels argument of text() with a cex less than 1 (which is now hard-coded by default, since there is no "..." argument processing) or will need to hack the margin sizes in the rest of the code that sets up the plot layout. I have tested it, and this does work when suitably used to replace the above section in an overwritten version of this function:
if (show.labels) {
par(mar = c(0, 0, 0, 4))
par(srt = 90)
obs.labels <- toupper(substr(x$labels[x$order], 1, 12))
if (is.null(members)) {
plot(0, type = "n", xlim = c(0.5, n.indiv + 0.5),
ylim = c(0, 1), xaxs = "i", axes = FALSE, xlab = "",
ylab = "")
text(1:n.indiv, 0, obs.labels, pos = 4, cex=0.5, col = col.down[groups.o])
}
精彩评论