Boxplot using cell array where each cell has different size
조회 수: 45 (최근 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')
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!