如何修改 MATLAB 系统发育树工具中的轴?

发布于 2024-11-06 21:40:42 字数 377 浏览 3 评论 0原文

我想为我在 Java 中生成的一些聚集集群显示漂亮的树状图。我将簇写入 Newick 格式的文件中。然后,我就可以得到一张几乎是我想要的漂亮照片。

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

在此处输入图像描述

不幸的是,X 轴不是我想要的。我更喜欢“反转”轴,因为聚类的迭代从右到左进行,例如 firstNamesetFirstName 在第一次迭代中聚类。有谁知道我该怎么做,或者至少关闭 X 轴标签? (无论如何,默认轴试图告诉我什么?)

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?)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

陪我终i 2024-11-13 21:40:42

首先,您需要访问绘制树状图的轴的句柄。如果它是唯一打开的图形,您可以使用函数 FINDALL ,如下所示:

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

现在,您想要更改的不是 x 轴方向,因为这也会反转绘制的树状图。您实际上只想更改 用于 x 轴刻度线的标签< /a>.如果你想关闭它们,你可以这样做:

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

现在,我不确定 x 轴意味着什么。在您的示例中,似乎每个分支点都位于沿 x 轴的整数值处,最左边的分支点(我猜是“根”)从 0 开始。包含 firstNamesetFirstName 的最右侧分支的位置为值 21。如果要更改轴标签,使最右侧分支位于 0 且最左边的分支位于 21,您可以按如下方式修改轴:

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

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).'));
冷月断魂刀 2024-11-13 21:40:42

这可以帮助你吗?

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

编辑
您可能会在此处找到很多有趣的内容。干杯!

This could help you?

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

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

岁月打碎记忆 2024-11-13 21:40:42

我需要类似的东西。我不知道Matlab R2021b 是否是新的,但现在有一个plot(tree) 函数,可以在常规Matlab 图形上绘制树。绘图后,我确定最大的 X 值并更新 XTickLabels。

B = [1 2 ; 3 4];
tree = phytree(B);
h = plot(tree);
ax = h.axes;

xdata = get(findobj(h.axes,'Type','Line'),'XData');
maxdist = max([xdata{:}]);
ax.XTickLabel = num2str(maxdist - str2double(ax.XTickLabel));

具有反向 Xtick 标签的系统发育树

I needed something similar. I don't know if it is new to Matlab R2021b, but there is now a plot(tree) function which will draw the tree on a regular Matlab figure. After plotting, I identify the largest X value and update the XTickLabels.

B = [1 2 ; 3 4];
tree = phytree(B);
h = plot(tree);
ax = h.axes;

xdata = get(findobj(h.axes,'Type','Line'),'XData');
maxdist = max([xdata{:}]);
ax.XTickLabel = num2str(maxdist - str2double(ax.XTickLabel));

Phylogenetic tree with reversed Xtick labels

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文