制作两个重叠条形图(如
Jonas suggests)的另一种方法是拨打一次调用
bar,将这些箱子绘制成一组
patch objects,然后修改
'FaceVertexCData' property以重新着色补丁面:
A = randn(1,100); %# The sample data
[N,binCenters] = hist(A); %# Bin the data
hBar = bar(binCenters,N,'hist'); %# Plot the histogram
index = abs(binCenters-0.7) < diff(binCenters(1:2))/2; %# Find the index of the
%# bin containing 0.7
colors = [index(:) ... %# Create a matrix of RGB colors to make
zeros(numel(index),1) ... %# the indexed bin red and the other bins
0.5.*(~index(:))]; %# dark blue
set(hBar,'FaceVertexCData',colors); %# Re-color the bins
这是输出: