Visualize data in a pivot-table like style
4 views (last 30 days)
Show older comments
Dear all,
I tried a lot, even the new Pivot function in Matlab 2023a, but I can not achieve what I am looking for.
I have this kind of data containing x, y and z values (See attached file "Testvalues.mat"). Sometimes there are more datapoints, sometimes less. And I want to have a chart looking like this (made in Excel for demonstration):
It is some kind of Pivottable, but I have diffiulties to achieve a visualization like this. The order is from -4500 to 12000 and 1500 to 10500 important.
Is there a way to get this output as a table with a Matlab function or code?
Thanks a lot and kind regards,
Sebastian
0 Comments
Accepted Answer
Harald
on 6 Feb 2024
Hi,
unstack and a few modifications should do the job:
load TestValues.mat
T = array2table(dataset8_max_langs);
T.dataset8_max_langs1 = cell2mat(T.dataset8_max_langs1);
T.dataset8_max_langs2 = cell2mat(T.dataset8_max_langs2);
T.dataset8_max_langs3 = string(T.dataset8_max_langs3);
T2 = unstack(T, "dataset8_max_langs3", "dataset8_max_langs1", ...
"VariableNamingRule","preserve");
T2 = fillmissing(T2, "constant", "", "DataVariables",@isstring);
T2 = sortrows(T2, "dataset8_max_langs2", "descend");
It seems like the data you have provided is not the same as the data you used for the chart. That makes it difficult to compare. Thus, please let me know if this is not the format you have been looking for. For example, you may want to use dataset8_max_langs2 instead of dataset8_max_langs1 in the unstack command.
Best wishes,
Harald
More Answers (0)
See Also
Categories
Find more on Logical 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!