Home | News | Documentation | Download

Empty plot getting createdusing TH1 and TGraph

So, here’s the code below that I wrote to plot eta vs dNch/dn (both eta and dNch.dn are arrays) but I am unable to get any plot. All it’s appearing is a blank canvas with the specified X and Y titles! The moment I am commenting out the TH1 declaration, I am getting the plot however, the ranges as specified in the TH1 is no more obtained. So, I need to keep the TH1 to obtain the plot in the right range yet when I am doing so, I am getting a blank canvas. Kindly help me.

                TCanvas *c1 = new TCanvas("c1","dNch/dn vs eta ",700,40,700,700);

		TH1 *fr = c1->DrawFrame(0.09,0,0.16,0.18);
		fr->SetTitle("#eta vs centrality");
  		fr->SetXTitle("dNch/dn");
  		fr->SetYTitle("#eta (GeV^{3})");
		fr->GetXaxis()->CenterTitle();
  		fr->GetYaxis()->CenterTitle();
		fr->Draw();
		
		TGraph *f1 = new TGraph(8, dN_charge, ar_eta);
		
		f1->Draw("same");
		f1->Write();
		
		f1->SetLineWidth(2);
		f1->SetLineStyle(14);
		f1->SetLineColor(14);	

		
		gPad->Update();
 TCanvas *c1 = new TCanvas("c1","dNch/dn vs eta ",700,40,700,700);

 TH1 *fr = c1->DrawFrame(0.09,0,0.16,0.18);
 fr->SetTitle("#eta vs centrality");
 fr->SetXTitle("dNch/dn");
 fr->SetYTitle("#eta (GeV^{3})");
 fr->GetXaxis()->CenterTitle();
 fr->GetYaxis()->CenterTitle();
		
 TGraph *f1 = new TGraph(8, dN_charge, ar_eta);
		
 f1->Draw("L");
 		
 f1->SetLineWidth(2);
 f1->SetLineStyle(14);
 f1->SetLineColor(14);	
	
 gPad->Update();

that worked! thank you.