Problem with XVariable property in stackedplot
Show older comments
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 Comments
Rik
on 15 Mar 2021
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
on 15 Mar 2021
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!