// histograms filled and drawn in a loop
void flatex() {
//
// To see the output of this macro, click begin_html here end_html
// Simple example illustrating how to use the C++ interpreter
// to fill histograms in a loop and show the graphics results
//Author: Rene Brun
TCanvas *c1 = new TCanvas("c1","Primer Enakomerna porazdelitev",2000,10,600,400);
c1->SetGrid();
// Create some histograms.
main = new TH1F("Flat","Enakomerna distribucija - samogenerirana spremenljivka",200,-5.5,5.5);
main->SetFillColor(41);
// Fill histograms randomly
gRandom->SetSeed(4444);
Int_t niter=1000000;
Float_t xsig=1.;
Float_t rho1=0.;
Float_t a=-4.;
Float_t b=+3.;
for ( Int_t i=0; iUniform();
xmain = (b-a)*rho1+a;
main->Fill(xmain);
}
gStyle->SetOptFit(0111);
main->GetYaxis()->SetTitle("N");
main->GetXaxis()->SetTitle("x");
main->Draw();
c1->Update();
TPaveStats *stats1 = (TPaveStats*)main->GetListOfFunctions()->FindObject("stats");
stats1->SetTextColor(2);
stats1->SetX1NDC(0.70); stats1->SetX2NDC(0.90); stats1->SetY1NDC(0.70);
c1->Update();
c1->Modified();
}