In the standard library, MATLAB histuses a command barto build it, but using barit alone gives you more flexibility. Moving to a barmatrix whose columns represent each bit of the histogram, it counts the graphs of each of these histograms in different colors, which is exactly what you want. Here is a sample code:
[xcounts,~] = hist(x,100);
[ycounts,~] = hist(y,100);
histmat = [reshape(xcounts,100,1) reshape(ycounts,100,1)];
bar(histmat, optionalWidthOfEachBarInPixelsForOverlap);
Documentation for bar here .
btown source
share