next up previous
Next: Dual Axes Example Up: Plotting Capabilities Previous: Simple Multicolumn Plot


Stacked Bar Graph

This example shows how a stacked bar chart can be constructed using Matlab. A brief discussion of the script follows the code snippet.

A=[
10,5413,1136,3420,1351,1350,7.516193,0.000000,179.851761,0.000000,188.441696
11,5413,1032,3420,1581,1581,7.247757,0.268435,136.902084,0.000000,145.223587
12,5413,946,3420,1770,1769,7.516193,0.268435,109.790100,0.000000,118.648468
13,5415,874,3420,1928,1928,7.247757,0.268435,86.704651,0.000000,95.563019
14,5415,812,3420,2062,2062,7.247757,0.805306,70.866959,0.000000,80.262199
15,5415,758,3420,2176,2175,8.589934,1.610613,58.787365,0.000000,70.598526
16,5417,710,3420,2272,2272,7.247757,2.684355,48.855251,0.000000,60.397976
17,5417,668,3420,2356,2356,7.247757,6.979322,41.607494,0.000000,57.445187
18,5417,632,3420,2435,2434,7.247757,16.106127,35.433479,0.000000,60.666412
19,5419,598,3420,2498,2498,6.979322,34.091305,30.601643,0.000000,73.819748
20,5419,568,3420,2557,2556,7.784628,70.866959,26.306675,0.000000,107.105743
21,5419,542,3420,2614,2581,7.516193,142.807663,23.353884,0.000000,174.483047
22,5419,508,3420,2617,2581,7.516193,279.709747,19.595789,0.000000,307.895477
];

maxtimeX = 9:0.05:23;
maxtimeY=60;
bestX=2462;
bestY=0:1:60;

dY=[A(:,7) A(:,8) A(:,9)];
h = bar(A(:,1), dY, 0.5, 'stack');
hold on
plot (maxtimeX, maxtimeY , 'r--');
hold off

legend(h, 'lg N vs Time for Log n computation', 'lg N vs Time for Harmonic Series computation','lg N (vs) Time for Bernouli Term computation');
title('Lg N (vs) Various Times', 'FontWeight', 'bold');
xlabel('Lg N [N = pow (2, x-axis)]');
ylabel('Time (in seconds) [Max permissible = 60]');
axis([9 23 0 320]);
Figure 9: Stacked Bar Graph
\begin{figure}\epsfig{file=src/vs1022_2462_new_times.eps, width=13cm}
\end{figure}


next up previous
Next: Dual Axes Example Up: Plotting Capabilities Previous: Simple Multicolumn Plot
Arvind Gopu 2006-03-24