How to change the font size of clustergram in Matlab?
我一直在尝试手动或通过编写命令来更改Matlab中clustergram的字体大小。 但是,它们都不起作用。 我不知道我做错了什么。 我也在网上搜索过,但只能找到类似的问题而没有答案。 这是我尝试过的。
1 2 3 | clusterobj = clustergram(data,'Rowlabel',c) % c is a cell array of strings for rowlabel h = addYLabel(clusterobj); set(h,'FontSize',2); |
或类似的东西
1 | addYLabel(clusterobj, c, 'FontSize', 2); |
要么
他们都没有工作。 我只是希望将c数组中字符串的字体大小更改为小得多的大小。 有人有什么主意吗? 非常感谢你,
尝试这个
1 | addYLabel(clusterobj , 'YourLabel', 'FontSize', 4) |
这将更改显示在图右侧的y标签" YourLabel"的大小。
但是,如果您想更改所有文本标签,则路程会更长一些。 使用我在搜索TMW支持页面时发现的以下代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | % Make all handles visible. This is necessary because clustergram % objects are created with 'HandleVisibility' property set to 'off'. set(0,'ShowHiddenHandles','on') % Get all handles from root allhnds = get(0,'Children'); % Find the handles that correspond to clustergram objects cgfigidx = strmatch('Clustergram',get(allhnds,'Tag')); cffighnd = allhnds(cgfigidx); fch = get(cffighnd,'Children'); fch = fch(strmatch('axes',get(fch,'Type'))); % Find all the text objects txtobj = findall(fch,'Type','Text'); % Set the font size of all text objects in clustergram (at last!) set(txtobj,'FontSize',5) |
编辑:
只需阅读@Jonas评论,就有一种更轻松,更优雅的方法来代替复杂的代码:
1 2 3 |
Chapeau,乔纳斯先生。