Hot to get an xlabel on a clustergram object?
2 views (last 30 days)
Show older comments
I have added and xlabel to a clustergram using addXlabel, but it disappears after "print to Figure". If I add a title using addTitle, this works fine If I add ylabel it is not visible at all Matlab version R 2013b
code: TM = clustergram(TMDS,'linkage','ward',... 'ColumnPdist','seuclidean','Cluster','col',... 'Dendrogram','default','RowLabels',labelsRow,'ColumnLabels',labelsCol,... 'Colormap', redbluecmap); cm = struct('GroupNumber',{8 9},'Annotation',{'A' 'B'},'Color',{'r','b'}); TM.RowGroupMarker = cm; addXLabel(TM, 'days')
>> size(TMDS)
ans =
11 23
>> class(TMDS)
ans =
double
1 Comment
Shivam Chaturvedi
on 29 Feb 2016
I tried adding the xlabel to the example given at the following link using all the properties for clustergram as you have mentioned above:
but I was able to use Print to Figure and it added the xlabel to the figure output successfully.
Can you add some reproduction code?
Accepted Answer
Adam Danz
on 3 Nov 2020
How to add an XLabel | YLabel | Title to a clustergram
Demo:
cgo = clustergram(rand(20,20));
addXLabel(cgo, 'X LABEL')
addYLabel(cgo, 'Y LABEL')
addTitle(cgo, 'TITLE')
How to access XLabel | YLabel | Title to a clustergram
2 Methods:
1) save the output handles to the addXLabel, addYLabel, addTitle function.
2) get the axis handle using findall along with the axis tag.
Demo:
% METHOD 1
cgo = clustergram(rand(20,20));
xlbl = addXLabel(cgo, 'X LABEL');
ylbl = addYLabel(cgo, 'Y LABEL');
ttl = addTitle(cgo, 'TITLE');
% METHOD 2
cgfig = findall(0,'type','figure', 'Tag', 'Clustergram'); % Fig handle
cgax = findobj(cgfig, 'type','axes','tag','HeatMapAxes'); % Axis handle
cgax.XLabel
cgax.YLabel
cgax.Title
0 Comments
More Answers (0)
See Also
Categories
Find more on Data Import and Management in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!