Set fixed bin nr in Y-axis on log scale for TH1F array

Dear ROOTers,

following problem:
a canvas is drawn with an array of 4 TH1F histograms. each histogram is filled with a different nr of values and plottet with LOG scale. To compare the histograms it would be convenient to have in the 4 different y-axis the same nr of bins, meaning to have 5 ticks exactly at 10, 10^2,10^3…
but for some reasons it is not possible.
The code shows one of my tries using GetYaxis()->Set(5,0,1500000.);

// Loop plots 3 1d-histograms
for(Int_t i= 0; i <= 3; i++) {
		
		canvas->cd(i);
		
		//pads[i]=(TPad*)(canvas->GetPrimitive(subCanName[i]));
		//pads[i]->SetLogy();
		
		h1fPt[i]->SetTitle(subCanTitle[i]);
		h1fPt[i]->GetXaxis()->SetTitle(subCanXaxis[i]);
		h1fPt[i]->GetXaxis()->SetLabelSize(.03);
		h1fPt[i]->GetYaxis()->SetLabelSize(.03);
		h1fPt[i]->SetMaximum(1500000);
		h1fPt[i]->Draw();
		
		pads[i]=(TPad*)(canvas->GetPad(i));
		pads[i]->SetLogy();
		
		h1fPt[i]->GetYaxis()->Set(5,0,1000000.);
}

it doesn’t work! ROOT makes (for some unknown reason) the ticks for each histogram in a different range. Has anyone an idea on this issue?

thanks for help,
flo

Can you send a small runnable script showing your problem ?

Thanks for the reply!
The following macro should represent my problem. 3 TH1F histograms are filled with FillRandom.
What i want to do is to set the nr of bins in y-Axis to a fixed nr (should be the same for every plot)

In the case of the macro i would like to have 4 equal bins ranging from 0. to the maximum value 1000000.

{
	TH1F* h1f[3];

	h1f[0] = new TH1F("h1f[0]","Random Gauss [0]" ,200,0,10);
   	h1f[1] = new TH1F("h1f[1]","Random Gauss [1]",100,0,10);
   	h1f[2] = new TH1F("h1f[2]","Random Gauss [2]",50,0,10);
	
   	h1f[0]->FillRandom("gaus",10000);
   	h1f[1]->FillRandom("gaus",1000000);
	h1f[2]->FillRandom("gaus",10000000);
	
	TCanvas* canvas	= new TCanvas("canvas","Test Makro",200,10,1100,850);
	TPad* pads[3];
	
	canvas->Divide(2,2);
	
	// Loop plots 3 1d-histograms
	for(Int_t i= 0; i <= 2; i++) 
	{
      
		canvas->cd(i+1);
			
		h1f[i]->SetFillColor(45);	
		h1f[i]->GetXaxis()->SetTitle("x-axis random");
		h1f[i]->GetXaxis()->SetLabelSize(.03);
		h1f[i]->GetYaxis()->SetLabelSize(.03);
		h1f[i]->SetMaximum(1000000.);
		
		h1f[i]->Draw();
		
		pads[i]=(TPad*)(canvas->GetPad(i+1));
		pads[i]->SetLogy();
		
		h1f[i]->GetYaxis()->Set(4,0.,1000000.); 
       	}
			
	// Update canvas 
	canvas->Modified();
	canvas->Update();
	
	canvas->Print("test_random.ps");
}

as one can see in the output of this macro it seems that root doesn’t allow me to set the y-bins as i want when i use log scale.

thanks for help

I do not understand your problem. The output of this macro is correct. You set the maximum of the histograms to 10^6 and that is what you get. By definition a 1D histogram does not have bins along the Y axis. So I do not really understand your statement:
What i want to do is to set the nr of bins in y-Axis to a fixed nr

what I want to do is to change the nr of “steps” (what i mean with bins) along the y-axis to a nr I choose! (maybe steps=ticks is the right word in english?)

for example:
the maximum of the histogram is 10^6, i want to have “steps” at 10, 10^3, 10^6. This would mean 3 steps along y-axis. In my understanding one can use hist->Set(3,0.,10^6) which should achieve this!?

or for another plot, again with maximum 10^6, i would like to have the following “steps” marked on the y-axis: 10,10^2,10^3,10^4,10^5,10^6 which would mean 6 steps: hist->Set(6,0.,10^6)

Is my understanding of Set() wrong? If yes what would achieve my goals?

thanks

I guess you mean the number of decades. The number of decades is largely set in some automatic way but you can change it by setting the number of divisions:

h1f[0]->GetYaxis()->SetNdivisions(503);

thanks a lot!!
problem solved