How to make side-by-side bars with the histogram() function?
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
When using the now-discouraged hist function to make histograms comparing two data sets, the default display was to put the bars of the two histograms side-by-side.
Now, with the new histogram function, the default behavior is to superimpose the two distributions, with some transparency.
What's the easiest way to get the old side-by-side behavior, while still using the new function?
0 Kommentare
Antworten (1)
Star Strider
am 18 Mai 2015
Bearbeitet: Star Strider
am 18 Mai 2015
I doubt that’s possible without some serious hacking.
A work-around:
A = randn(100,2);
[h1,edges] = histcounts(A(:,1), 10);
[h2,edges] = histcounts(A(:,2), 10);
figure(1)
ctrs = edges(1)+(1:length(edges)-1).*diff(edges); % Create Centres
bar(ctrs, [h1 ;h2]')
0 Kommentare
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!