![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/188647/image.jpeg)
How to plot multiple histograms, each with fitting in a single figure?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ishita agrawal
am 13 Dez. 2017
Beantwortet: Ameer Hamza
am 20 Mai 2018
I have 5 datasets. I have to plot the histogram for each of them in a single figure. I want to fit each histogram individually using the normal distribution. I have attached the data along with the image of histograms plotted in a single figure, however, fitting is missing.
0 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 20 Mai 2018
Here is a way to produce several histograms side by side as given in the attached image.
% preparing sample dataset
data{1} = rand(1, 1000);
data{2} = 3*rand(1, 1200);
data{3} = 2*rand(1, 800);
data{4} = 5*rand(1, 500);
data{5} = 4*rand(1, 1000);
h = histogram(data{1});
hold on
for i = 2:length(data)
[~,edges] = histcounts(data{i})
h = histogram(data{i} + h.BinEdges(end), h.BinEdges(end) + edges)
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/188647/image.jpeg)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Histograms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!