gpt4 book ai didi

matlab - 如何在 Matlab 中更改 clustergram 的字体大小?

转载 作者:行者123 更新时间:2023-12-02 22:15:12 24 4
gpt4 key购买 nike

我一直在尝试手动或通过编写命令来更改 Matlab 中 clustergram 的字体大小。但是,它们都不起作用。我不知道我哪里做错了。我也在网上搜索过,但只能找到没有答案的类似问题。这是我尝试过的。

clusterobj = clustergram(data,'Rowlabel',c) % c is a cell array of strings for rowlabel
h = addYLabel(clusterobj);
set(h,'FontSize',2);

或者类似的东西

addYLabel(clusterobj, c, 'FontSize', 2);

set(gca,'FontSize',2);

它们都不起作用。我只是希望将 c 数组中字符串的字体大小更改为更小的大小。任何人有任何想法?非常感谢,

最佳答案

试试这个

addYLabel(clusterobj , 'YourLabel', 'FontSize', 4)

这将更改将出现在绘图右侧的 y 标签“YourLabel”的大小。

但是,如果要更改所有的文本标签,那么路就有点长了。使用我在搜索 TMW support pages 时发现的代码:

% 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 评论,有一种更简单、更优雅的方式来代替复杂的代码:

figureHandle = gcf;
%# make all text in the figure to size 14 and bold
set(findall(figureHandle,'type','text'),'fontSize',4,'fontWeight','bold')

起首,乔纳斯先生。

关于matlab - 如何在 Matlab 中更改 clustergram 的字体大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14594674/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com