how to manually calculate the stacked bar
Mostrar comentarios más antiguos
Hello everyone,
I am struggling to understand how MATLAB is calculating its 'stacked' bar plots.
In my experiment, I take the difference of several vectors and I end up with positive and negative values. then I plot them as 'stacked' bars. I just want to understand how MATLAB reached to that plot because I could not do the computation myself. in their help document they say:
"If y is an m-by-n matrix, then bar displays m bars where each bar height is the sum of the elements in the row. Each bar is multicolored. Colors correspond to distinct elements and show the relative contribution each row element makes to the total sum"
How are they showing that bar height is the sum of all the elements and at the same time show the relative contribtion of each elements that makes to the total sum???!!!
I want to be able to manually calculate the stacked bar myself then I'll plot them as a normal plot as a one color because I am more interested in the net rather than the individual contribution. also, I'll be able to add errorbars and do more statisitics.
an example:
N = [0.104289664611676, -0.328634522539032, 0.534512715012202, -0.115290712257105, -0.0873978289502759, -0.310172844013392, -0.101568169901694, 0.0782078439567624, 0.226053854080858 ; 0.104853556666576, 0.0277767793523505, 0, 0, 0, -0.0277767793523505, -0.00257839874920164, -0.102275157917374, 0];
P = [-0.359650600161484, -0.00882683924118048, 0.151008014196010, 0.214974668975995, -0.120598651574417, -0.0425338382042942, -0.232471668177692, -0.0686700596309392, 0.466768973818002 ; 0, 0.166302832327649, 0, 0, 0.0690888201010693, -0.0769324569974460, -0.289045619213330, 0.351763782126669, -0.221177358344612];
figure;
subplot(1,2,1)
bar(N,'stacked')
subplot(1,2,2)
bar(P,'stacked')
Thanks!!
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Data Distribution Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!