Boxplot using cell array where each cell has different size
42 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
dpb
le 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 commentaires
dpb
le 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.
Plus de réponses (1)
Adam Danz
le 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')
Voir également
Catégories
En savoir plus sur Axis Labels dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!