Filter löschen
Filter löschen

Group bar graph, with different group sizes?

16 Ansichten (letzte 30 Tage)
Tracy Campbell
Tracy Campbell am 12 Dez. 2017
Beantwortet: Chris Perkins am 14 Dez. 2017
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!

Antworten (1)

Chris Perkins
Chris Perkins am 14 Dez. 2017
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.

Kategorien

Mehr zu Dialog Boxes finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by