Friday, 5 August 2016

MATLAB Programming 50 - bar charts (Example)

Display one bar for each row of the matrix. The height of each bar is the sum of the elements in the row.



y = [2 2 3; 2 5 6; 2 8 9; 2 11 12];
bar(y,'stacked')



Create a figure with two subplots. In the upper subplot, plot a bar graph. In the lower subplot, plot a stacked bar graph of the same data.


y = [1 2 3; 4 5 6];
ax1 = subplot(2,1,1);
bar(ax1,y)

ax2 = subplot(2,1,2);
bar(ax2,y,'stacked')


Create a bar graph using red bars


y = [75 91 105 123.5 131 150 179 203 226 249 281.5];
bar(y,'r')




No comments:

Post a Comment