Group bar graph, with different group sizes?

11 visualizaciones (últimos 30 días)
Tracy Campbell
Tracy Campbell el 12 de Dic. de 2017
Respondida: Chris Perkins el 14 de Dic. de 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!

Respuestas (1)

Chris Perkins
Chris Perkins el 14 de Dic. de 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.

Categorías

Más información sobre Data Exploration en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by