How do I make a stacked 3-D bar plot from a 3-D matrix?
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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?
Risposta accettata
MathWorks Support Team
il 27 Giu 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Annotations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!