フィルターのクリア

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 Center および File ExchangeDialog Boxes についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by