Boxplot using cell array where each cell has different size
70 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Enrico Gambini
am 19 Mai 2021
Kommentiert: Enrico Gambini
am 20 Mai 2021
Hello to everyone!
I would like to obtain a single graph with boxplots using a 1x40 cell array, each cell has a different number of elements (vectors of type double) and represents observations for a single year .
I would like to group the boxplots from year 1981 to 2020 in a single graph.
Hope that my question is clear, thank you!
0 Kommentare
Akzeptierte Antwort
dpb
am 19 Mai 2021
Fill each cell with NaN to the same size vector and then convert to an array. boxplot will ignore the NaN missing value indicators.
3 Kommentare
dpb
am 19 Mai 2021
boxplot() is written to take a double array, not cell array, so not simply, no. It's easy enough to just augment the data and the result is/will be the same.
The alternative is to add each on top of an existing axes; the code to do that would be more complex than just rounding out the existing data.
Weitere Antworten (1)
Adam Danz
am 19 Mai 2021
boxplotGroup from the file exchange will accept the cell array you described.
c = arrayfun(@(i){rand(randi([5,20]),1)},1:40)
years = compose('%d',1981:2020)
boxplotGroup(c, years)
xlabel('year')
Siehe auch
Kategorien
Mehr zu Axis Labels 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!