Limits on axis of TGraph

Hi,

I need to plot three graphs in log scale, with a maximum and a minimum on the y axis.
How can I do it ?

I attached the three data files with a root code which I though was not so wrong but does not fix the right limits on the y axis.

void Opacity(char *infile="opacity_pair.txt",char *infile2="opacity_egamma.txt",char *infile3="opacity_ic.txt"){

    TCanvas *c1 = new TCanvas("c1","c1",800,800);

    c1->cd(1);
    c1->SetLogy();
    c1->SetLogx();

  
    TGraph *gr1 = new TGraph(infile);
    TGraph *gr2 = new TGraph(infile2);
    TGraph *gr3 = new TGraph(infile2);

      gr1->SetLineStyle(4);
      gr2->SetLineStyle(4);
      gr3->SetLineStyle(4);
            
  
  gr1->GetHistogram()->SetTitle("Optical Depth");
  gr1->GetHistogram()->GetYaxis()->SetMaximum(10000);
  gr1->GetHistogram()->GetYaxis()->SetMinimum(0.0001); 
  gr1->GetHistogram()->GetXaxis()->SetTitle("Energy (GeV)");

  gr1->SetLineColor(4);
  gr1->SetLineWidth(3);
  gr2->SetLineColor(2);
  gr2->SetLineWidth(3);
  gr3->SetLineColor(6);
  gr3->SetLineWidth(5);

  char text1[100];
  char text2[100];

  sprintf(text1,"");  
  sprintf(text2,"");

  TText *t1 = new TText(10,0.7,text1);
  TText *t2 = new TText(7,0.4,text2);

  t1->SetTextSize(0.038);
  t2->SetTextSize(0.038); 
  t1->SetTextColor(kBlue);
  t2->SetTextColor(kRed);

  gr1->Draw("ALP");
  gr2->Draw("LP");
  t1->Draw();
  t2->Draw();

}

Thanks a lot,

Sabrina
opacity_pair.txt.gz (697 Bytes)
opacity_ic.txt.gz (753 Bytes)
opacity_egamma.txt (2.54 KB)

You should do:

gr1->GetHistogram()->SetMaximum(10000);             
gr1->GetHistogram()->SetMinimum(0.0001);
1 Like