Filter löschen
Filter löschen

How to: simple stack bar

1 Ansicht (letzte 30 Tage)
Hello kity
Hello kity am 8 Feb. 2013
Hi
I want to stack a bar but it gives error
X as Y same lenght
i have a simple matrix,
A=[76 96 68 15 112 160]
I plot:
bar(1,A(1,1),'c')
hold on
bar(2,A(1,2),'y')
till bar 6 with each own color, bar 7 should be total of them off them but stacked and with each of them with their representative color.

Akzeptierte Antwort

the cyclist
the cyclist am 8 Feb. 2013
Here is one way:
A = [76 96 68 15 112 160];
A6 = nan(6,6);
A6(1:7:36) = A;
A7 = [A6;A];
bar(A7,'stacked');
  1 Kommentar
Hello kity
Hello kity am 8 Feb. 2013
hmm much shorter than my code :)
thx you

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 8 Feb. 2013
Bearbeitet: Azzi Abdelmalek am 8 Feb. 2013
close
A=[76 96 68 15 112 160]
cl='rgbkcm'
for k=1:6
bar(k,A(k),cl(k))
hold on
end
set(gca,'xtick',1:6)

Kategorien

Mehr zu Animation finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by