Question

I want to display pretty dendrograms for some agglomerative clusters I am generating in Java. I write the clusters out to a file in Newick format. Then, I can get a pretty picture that is almost what I want.

tr = phytreeread('myfile.tree')
phytreetool(tr)

enter image description here

Unfortunately, the X axis is not what I want. I would prefer to "reverse" the axis, because the iterations of the clustering progress from right to left, e.g. firstName and setFirstName get clustered in the first iteration. Does anybody know how I can do that, or at least turn off the X axis labeling? (What is the default axis trying to tell me anyway?)

Was it helpful?

Solution

First, you will need to gain access to the handle for the axes in which the dendrogram is plotted. If it's the only figure open, you can use the function FINDALL like so:

phyAxes = findall(0,'Type','axes');

Now, what you want to change isn't the x-axis direction, since this will reverse the plotted dendrogram as well. You actually want to change just the labels used for the x-axis tick marks. If you want to just turn them off, you can do this:

set(phyAxes,'XTick',[]);

Now, I'm not sure what the x-axis is meant to tell you. In your example, it appears that each branch point is positioned at an integer value along the x-axis starting at 0 for the left-most branch point (the "root", I guess). The right-most branch containing firstName and setFirstName is positioned at a value of 21. If you want to change the axis labeling so that the right-most branch is at 0 and the left-most branch is at 21, you can modify the axes as follows:

set(phyAxes,'XTick',0:21,'XTickLabel',num2str((21:-1:0).'));

OTHER TIPS

This could help you?

set(gca,'XDir','reverse')

EDIT You may find a lot of interesting here. Cheers!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top