www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/SpecifyStylesForHorizontalBarGraphExample.m
%% Specify Style for Horizontal Bar Graph % Create a figure with four subplots. In each subplot, create a horizontal % bar graph using a different style option for each graph. % Copyright 2015 The MathWorks, Inc. x = [2,4]; y = [1,2,3,4;... 5,6,7,8]; figure; subplot(2,2,1); barh(x,y,'grouped'); % groups by row title('Grouped Style') subplot(2,2,2); barh(x,y,'stacked'); % stacks values in each row together title('Stacked Style') subplot(2,2,3); barh(x,y,'hist'); % centers bars over x values title('hist Style') subplot(2,2,4); barh(x,y,'histc'); % spans bars over x values title('histc Style')