Using the function hist(), you can build this:![[link] (http://nl.mathworks.com/help/examples/graphics/CreateHistogramBarPlotwithMatrixInputExample_01.png).](https://fooobar.com//img/08c91c510223358918cfc380b8675268.png)
Matlab recommends using histogram()instead hist().
The construction of several histograms in the same graph with the help histogram()leads to the following:![[link] (http://nl.mathworks.com/help/examples/matlab/PlotMultipleHistogramsExample_01.png)](https://fooobar.com//img/8fdf6a20c5d00158ad446b0bb9f765d7.png)
Columns overlap and not side by side.
Is it possible to plot a histogram with columns side by side in the same graph using a function histogram()? If so, how do I do this?
Code snippet:
a = randn(100, 2);
edges = -3:3;
xbins = edges(1:end-1)+0.5;
figure(1)
hist(a, xbins)
figure(2), hold on
histogram(a(:, 1), edges)
histogram(a(:, 2), edges)
source
share