Cas*_*sie 2 matlab plot font-size heatmap axis-labels
我一直在尝试手动或通过编写命令来改变Matlab中的clustergram的字体大小.但是,它们都没有奏效.我不知道我做错了什么.我也在网上搜索,但只能在没有答案的情况下找到类似的问题.这是我尝试过的.
clusterobj = clustergram(data,'Rowlabel',c) % c is a cell array of strings for rowlabel
h = addYLabel(clusterobj);
set(h,'FontSize',2);
Run Code Online (Sandbox Code Playgroud)
或类似的东西
addYLabel(clusterobj, c, 'FontSize', 2);
Run Code Online (Sandbox Code Playgroud)
要么
set(gca,'FontSize',2);
Run Code Online (Sandbox Code Playgroud)
他们都没有工作.我只是希望将c数组中字符串的字体大小更改为更小的大小.任何人有任何想法?非常感谢你,
试试这个
addYLabel(clusterobj , 'YourLabel', 'FontSize', 4)
Run Code Online (Sandbox Code Playgroud)
这将改变将出现在图表右侧的y标签"YourLabel"的大小.
但是,如果要更改所有文本标签,那么道路会更长一些.使用此代码,我找到了搜索TMW支持页面:
% 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)
Run Code Online (Sandbox Code Playgroud)
编辑: 只是阅读@Jonas评论,有一个更简单,更优雅的方式,而不是精心设计的代码:
figureHandle = gcf;
%# make all text in the figure to size 14 and bold
set(findall(figureHandle,'type','text'),'fontSize',4,'fontWeight','bold')
Run Code Online (Sandbox Code Playgroud)
Chapeau,Jonas先生.
| 归档时间: |
|
| 查看次数: |
1950 次 |
| 最近记录: |