필터 지우기
필터 지우기

Group bar graph, with different group sizes?

조회 수: 16 (최근 30일)
Tracy Campbell
Tracy Campbell 2017년 12월 12일
답변: Chris Perkins 2017년 12월 14일
Hi all,
I'm trying to make a bar graph with groups - but not all groups are the same size.
My current code is as follows:
y = [13.2764279; -2.011230558 5.146663618 5.7332464; -22.2335537 -5.60238553 -4.9771596; -47.575537 -18.405 -23.2868517];
figure1=figure;
bar(y)
xticklabels({'Baseline';'10% Perennials, 10% Reduction'; '10% Perennials, No reduction'; 'No increase, 10% Reduction';'25% Perennials, 25% Reduction'; '25% Perennials, No reduction'; 'No increase, 25% Reduction';'50% Perennials, 50% Reduction'; '50% Perennials, No reduction'; 'No increase, 50% Reduction'});
xtickangle(45)
xticks(1:1:length(category))
Besides adding in 0 or NaN - are there any other options? Thanks for the help!

답변 (1개)

Chris Perkins
Chris Perkins 2017년 12월 14일
Hi Tracy,
As a matrix in MATLAB cannot have a different number of columns per row, you will have to pad any rows that are not full length (in your example, only row 1) with NaN or 0, as you mention in your post.

카테고리

Help CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by