How do I make a stacked 3-D bar plot from a 3-D matrix?

10 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 27 de Jun. de 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);

Más respuestas (0)

Categorías

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

Etiquetas

Productos


Versión

R14SP1

Community Treasure Hunt

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

Start Hunting!

Translated by