How do I make a stacked 3-D bar plot from a 3-D matrix?
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
If I have 3-dimensional matrix, how would I plot a bar plot where I want one frame to be a certain level of the 'stacked' bar plot and the next frame stacked on top and so forth?
Akzeptierte Antwort
MathWorks Support Team
am 27 Jun. 2009
Creating a stacked 3-dimensional bar plot is possible using the BAR3 function. A 2-dimensional matrix is collpased when bar3(x,'stacked') option is used. Starting from a 3-D matrix, we grab the first slice of the 3-D matrix and transpose it into a 2-D matrix. Consequently, feed it into bar3. This process will produce the normal output shown in doc bar3.
Next, access the 'xdata' in the of the current axes children and increment it to shift the bars so when BAR3 is called for the next slice of the 3-D matrix, the columns will not overlap. The attached file bar3_stacked.m demonstrates this process.
The following will create a random set of 3D stacked bars using the bar3_stacked function attached to this solution:
a = rand(3,4,5);
bar3_stacked(a);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations 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!