Removing Some Tick Mark Labels, but not All

As the title says, I want to know how to remove some of the tick mark labels, but not all of them.

The use-case is as follows. I have a histogram with two peaks, but one is much larger than the other. I want to display both peaks in a single plot, but using log scale distorts the shape of the peaks. Therefore, having an inset plot such that both plots share the x-axis, but have different y-axes. I have the following code as an example of this method.

{
	//Make a test-case histogram
	TH1* hist = new TH1F("hist","",2000,0,2000);
	TRandom3 rand;
	for (int i=0; i<1e7; i++) {
		hist->Fill(rand.Gaus(500,100));
	}
	for (int i=0; i<1e4; i++) {
		hist->Fill(rand.Gaus(1500,100));
	}


	// Draw the main histogram
	TCanvas* main_can = new TCanvas;
	hist->SetStats(0);
	hist->GetXaxis()->SetRangeUser(0,2000);
	hist->GetXaxis()->SetNdivisions(-210);
	hist->Draw();

	// Draw the blow-up inset on the right.
	// TPad left/right/top/bottom chosen to make x-axis coincide.
	TPad* inset_pad = new TPad("inset_pad","",0.45,0.05,0.95,0.55);
	inset_pad->SetFillStyle(4000);
	inset_pad->SetBorderSize(0);
	inset_pad->Draw();
	inset_pad->cd();

	TH1* inset = (TH1*)hist->Clone();
	inset->GetXaxis()->SetRangeUser(1000,2000);
	inset->GetXaxis()->SetLabelOffset(999);
	inset->GetXaxis()->SetLabelSize(0);
	inset->GetXaxis()->SetNdivisions(-205);
	inset->Draw();
}

This works well, except that the 0 of the inset y-axis overlaps with the x-axis of the main plot. Is there a way to remove this 0, without removing all the y-axis labels?

try to change a bit the minimum of the inset Y axis. Now it is 0 … you can try to set it to 0.0001. The label 0 should disapear

Thank you. That works seems to work in some of the cases I have, including the example.

Follow-up question. If I have a low number of divisions in y-axis of the inset, as shown below, then the minumum gets listed as 0.001, instead of being dropped entirely. Is there a way to avoid this?

[code]{
//Make a test-case histogram
TH1* hist = new TH1F(“hist”,"",2000,0,2000);
TRandom3 rand;
for (int i=0; i<1e7; i++) {
hist->Fill(rand.Gaus(500,100));
}
for (int i=0; i<1e4; i++) {
hist->Fill(rand.Gaus(1500,100));
}

// Draw the main histogram
TCanvas* main_can = new TCanvas;
hist->SetStats(0);
hist->GetXaxis()->SetRangeUser(0,2000);
hist->GetXaxis()->SetNdivisions(-210);
hist->Draw();

// Draw the blow-up inset on the right.
// TPad left/right/top/bottom chosen to make x-axis coincide.
TPad* inset_pad = new TPad("inset_pad","",0.45,0.05,0.95,0.55);
inset_pad->SetFillStyle(4000);
inset_pad->SetBorderSize(0);
inset_pad->Draw();
inset_pad->cd();

TH1* inset = (TH1*)hist->Clone();
inset->SetMinimum(0.001);
inset->GetXaxis()->SetRangeUser(1000,2000);
inset->GetXaxis()->SetLabelOffset(999);
inset->GetXaxis()->SetLabelSize(0);
inset->GetXaxis()->SetNdivisions(-205);
inset->GetYaxis()->SetNdivisions(2);
inset->Draw();

}
[/code]

The Y axis in the inset does clearly have non optimize binning. You should let il optimize… do not put a negative number of divisions.

In this example, I did allow the inset to optimize the binning, as far as I understood. The line was “inset->GetYaxis()->SetNdivisions(2);”. The line above that, with the negative number of divisions, was for the x-axis.

Yes the optimiser is lost with to few number of divisions and it switch to non optimized automatically. Th best I can propose you is:
inset->GetYaxis()->SetNdivisions(4);