Boxplot using cell array where each cell has different size
29 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
dpb
2021 年 5 月 19 日
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 件のコメント
dpb
2021 年 5 月 19 日
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.
その他の回答 (1 件)
Adam Danz
2021 年 5 月 19 日
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')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/622993/image.png)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!