www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/AdjustHistogramPropertiesExample.m

    %% Adjust Histogram Properties
% Generate 1,000 random numbers and create a histogram. Return the
% histogram object to adjust the properties of the histogram without
% recreating the entire plot.

% Copyright 2015 The MathWorks, Inc.

x = randn(1000,1);
h = histogram(x)

%%
% Specify exactly how many bins to use.
h.NumBins = 15;

%%
% Specify the edges of the bins with a vector. The first value in the
% vector is the left edge of the first bin. The last value is the right
% edge of the last bin.
h.BinEdges = [-3:3];

%%
% Change the color of the histogram bars.
h.FaceColor = [0 0.5 0.5];
h.EdgeColor = 'r';