TCanvas Histo

Dear expert,
I want to plot histo, h1 and h2 on same canvas c1, but the code mentioned below Draw h1 and h3 on same canvas. Is there a way to draw h1 and h2 on same canvas without closing/deleting c1, also not defining any new canvas for h3. i.e I want h3 draw on default canvas… I also don’t want to change the ordering of drawing of histos.

void can()

{
 

  TH1F *h1 =  new TH1F("h1","par",540,0,540);
   TH1F *h2 =  new TH1F("h2","Ch",100,0,400);
    TH1F *h3 =  new TH1F("h3","Ch2",100,0,400);
 
  TCanvas *c1 = new TCanvas("c1","param");
  c1->Divide(2,1);
  c1->cd(1);
  h1->Draw();
  c1->cd(2);
   	h2->Draw();
	h3->Draw();

	
}

h3->Draw("SAME");

I want to draw h3 on different(default) canvas, without defining a canvas

new TCanvas(); h3->Draw();

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.