Problem with XVariable property in stackedplot
显示 更早的评论
Hey,
I am new to the forum so please bear with me :)
I am trying to get the subplot to display the actual label of the row when I hover over it (see the blue number at the top of the uppermost plot in the image).

The names of the rows (here blood metabolite values) are stored in the following two structures (first is a string array and second is a table)
metabolite_labels = string(data.Properties.VariableNames(4:width(data)))'
lincorr_hkt = array2table(hkt_corr_res,...
'VariableNames',{'a' 'm' 'R2' 'rho' 'p-value' 'Significant?' 'Strength' 'Missing Values (%)'},...
'RowNames',metabolite_labels)


I have tried using metabolite_label as a string array as well as the RowName property from the lincorr_hkt table, both give me the same error. I dont understand what type it needs to be?
figure
s = stackedplot(lincorr_hkt,'XVariable',lincorr_hkt.Properties.RowNames)
Error using stackedplot (line 100)
'XVariable' value must be a character vector, a string scalar, a positive integer, or a logical array with one true
element.
figure
s = stackedplot(lincorr_hkt,'XVariable',metabolite_labels)
Error using stackedplot (line 100)
'XVariable' value must be a character vector, a string scalar, a positive integer, or a logical array with one true
element.
Any help would be much appreciated :)
2 个评论
Rik
2021-3-15
Since your x-variable seems to be a categorical array, instead of a numeric array, you could try to set them as tick labels. That will make the axis look very messy, so you might need to set the font to something very small to hide the text.
Philipp Brunnbauer
2021-3-15
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
