Create a grouped boxplot
296 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
NA
am 7 Jul. 2021
Kommentiert: Adam Danz
am 22 Sep. 2022
I have 3 groups of data A, B, and C.
A = rand(100,8);
B = rand(100,8)*2;
C = rand(100,8)*4;
I want to plot Box chart of grpup A,B and C.
The internal label of each group is {'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h'}.
data = {A,B,C};
boxplotGroup(data, 'PrimaryLabels', {'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h'}, ...
'SecondaryLabels',{'A', 'B' 'C'}, 'InterGroupSpace', 3)
But I got this error.
Error using assert (line 5)
The number of primary labels must equal either the number of bars per group
(3) or the number of total bars (24).
Error in boxplotGroup (line 155)
assert(ismember(numel(p.Results.primarylabels),[nMembers,
nMembers*nGroups]), ...
Error in (line 13)
boxplotGroup(data, 'PrimaryLabels', {'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h'}, ...
0 Kommentare
Akzeptierte Antwort
Christopher McCausland
am 7 Jul. 2021
Bearbeitet: Christopher McCausland
am 7 Jul. 2021
Hi NA,
From the documentation here (See section boxplotGroup(__,'primaryLabels',c) ) the number of primary lables should match the number of boxplotGroups. i.e. you appear to be plotting three box plots (A,B,C) but trying to give these box plots eight names ('a' 'b' 'c' 'd' 'e' 'f' 'g' 'h').
I beleive that you are trying to show something like the last example in boxplotGroup(__,'secondaryLabels',s) (shown below) in which case swap your primary and secondary labels.
Let me know if that helps,
Christopher
5 Kommentare
Christopher McCausland
am 5 Sep. 2022
Verschoben: Adam Danz
am 22 Sep. 2022
Hi Edward,
This question should really be asked as a question in it's own right and not as an answer to a previously solved question.
I would however suggest making the labels and supplying them to the primary labels input rather than trying to make them on the fly.
Here is some further help with a previously solved similar problem.
Kind Regards,
Christopher
Adam Danz
am 22 Sep. 2022
To fix this, set the axis tick label interpreter to tex
h = boxplotGroup(__);
h.axis.TickLabelInterpreter = 'tex';
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Bar Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!