Baterako edo elkarren ondoko histograma (ingelesez, back to back histogram) biak datu berdinekin eratu dira (klik egin irudian jatorriko datuak jakiteko): ezker aldean, baterako histogramak maiztasun absolutuekin eratu dira: bi datu multzoak 35-40 tartearen inguruan biltzen dira, baina B datu-multzoan barra luzeagoa denez, irudiko luke B datu-multzoa tarte horretan zentratuago dagoela; irudipen faltsua da, ordea, horren arrazoia B datu-multzoan A datu-multzoan baino askoz ere datu gehiago izatea baita. Beraz, histogramak modu homogeneoan alderatu ahal izateko, dentsitateekin eratu behar dira, eskuin aldean egiten den bezala. Eskuin aldeko baterako histograman ikusten da, barra luzeagoa, dentsitatez, A datu-multzoak duela eta beraz hori dela, barra luzeagoaren irizpidearekin, datu multzo zentratuena.
English: This  chart was created with R. Back-to-back histograms for the same data, split in two sets. In the left side, histogram is created with absolute frequencies, and with densities in the right side. In the first one, it looks like, "B datuak" histogram is better centered, because the 35-40 bar is longer tha the "A datuak" one, but that is because of the effect of the sample size: there is much more data in the "B datuak" set. So, it is better to compare two histograms with the densities, as it is shown in the right side. Source code: Adatuak=rnorm(40,40,6) Bdatuak=rnorm(80,40,8) Adatuak [1] 39.97066 43.77735 32.52783 46.24845 27.93381 38.06025 40.16100 29.41729 [9] 42.90927 38.08922 40.64468 42.29734 43.95698 38.00443 40.01753 34.34909 [17] 27.57535 46.42848 42.73618 37.44475 43.01344 39.67734 42.07484 34.55130 [25] 38.15745 36.58956 31.75970 36.32229 44.71220 39.15733 43.22294 36.94764 [33] 36.54390 37.79979 29.99334 37.82112 43.49658 40.97438 36.27982 47.60324 Bdatuak [1] 30.74745 34.03354 50.55827 50.34940 33.92681 39.82610 36.19401 52.32432 [9] 53.82607 34.26134 45.97319 38.27179 38.37459 32.73507 38.90548 32.44860 [17] 30.58975 37.52801 47.63442 41.86883 43.96290 24.46212 49.97131 30.80917 [25] 37.44040 47.22991 36.39881 56.02536 33.30398 38.27312 40.03014 49.41013 [33] 47.35079 37.19053 44.91395 34.89235 47.17949 36.20301 39.37896 38.19084 [41] 38.95850 36.42298 34.61784 28.50686 38.02944 23.57014 53.61240 34.56919 [49] 26.65668 51.67273 36.72310 32.09942 24.76130 34.14042 41.73991 55.70082 [57] 41.90775 38.11109 43.13750 38.58608 36.85659 39.27506 40.50018 48.52618 [65] 46.68819 41.53765 46.79334 44.16655 34.93532 36.57027 38.02441 47.62884 [73] 40.22719 51.95984 36.18291 35.55269 34.85261 29.07082 39.18511 33.19069 png(filename = "ondoko_histogramak_004.png", width=1100, height=500) par(mar=c(5,5.3,4,2),oma=c(1,1,1,1)) par(mfrow=c(1,2)) tarteak=seq(15,65,by=5) library(Hmisc) histo=histbackback(Adatuak,Bdatuak, probability=F,brks=tarteak,axes=F) axis(1,at=seq(-25,25,by=5),labels=c(25,20,15,10,5,0,5,10,15,20,25)) axis(2,at=seq(0,12,by=1),labels=seq(15,75,by=5),las=1) barplot(-histo$left,col=c("navajowhite"),horiz=TRUE,space=0,add=TRUE, axes=FALSE) barplot(histo$right,col=c("lightblue1"),horiz=TRUE,space=0, add=TRUE,axes=FALSE) mtext(c("A datuak", "B datuak"), side=1, at=c(-10,10),line=3) title("Histogramak, maiztasun absolutuekin") histo=histbackback(Adatuak,Bdatuak, probability=T,brks=tarteak,axes=F) axis(1,at=seq(-0.08,0.08,by=0.02), labels=c(0.08,0.06,0.04,0.02,0,0.02,0.04,0.06,0.08)) axis(2,at=seq(0,12,by=1),labels=seq(15,75,by=5),las=1) barplot(-histo$left,col=c("navajowhite"),horiz=TRUE, space=0,add=TRUE,axes=FALSE) barplot(histo$right,col=c("lightblue1"),horiz=TRUE, space=0,add=TRUE,axes=FALSE) mtext(c("A datuak", "B datuak"), side=1, at=c(-0.05,0.05), line=3) title("Histogramak, dentsitateekin") dev.off()