Behavior of TF1 functions leaving the visible area

Hello,

for my diploma thesis I created a plot (TF1), with three different functions. One of them leaves (and this is intended), the upper border of the graph area before it reaches the right border.
This unfortunately leads to ROOT drawing an extension of the function (with the same color) directly on the border beginning from the point where the function left the field of view.
I searched the references and forums for a long time but did not find out how to turn this “functions-graph-is-not-visisble-but-we-want-to-show-you-it’s-still-there” thing off.

Any help?

Thanks in advance!

Hi,

Please provide a running example (as well as clear indication of what you see vs what you would like to have seen) to help in solving this issue.

Thanks,
Philippe.

{
    float ObsFTot = 1835/(365.0 * 24);
    float ObsFGod = 1086/(365.0 * 24);
    float ClearSkyF = 0.6;
    float WMax = 60;
    float GRBpAnno = 300 / 3.2;
    TCanvas* c = new TCanvas("angular_dist","Tracking Duration",0,0,800,600);
    TF1* f1 = new TF1("angular","[0] * [1] * 2*pi*(1-cos(x * pi/180.0)) / (4*pi)",0,WMax);
    TLegend *leg = new TLegend(0.6, 0.83, 0.89, 0.89);
    leg->SetFillColor(0);
    c->cd(1);
    f1->SetParameter(0,GRBpAnno);
    f1->SetParameter(1,1);
    f1->SetTitle("Annual GRBs within an angular offset");
    f1->GetXaxis()->SetTitle("Angular offset in deg");
    f1->GetYaxis()->SetTitle("Annual GRBs");
    f1->GetXaxis()->CenterTitle();
    f1->GetYaxis()->CenterTitle();
    f1->GetXaxis()->SetRangeUser(0,WMax);
    f1->GetYaxis()->SetRangeUser(0,3.5);
    f1->SetLineColor(2);
    f1->SetLineWidth(1);
    f1->Draw();
    leg->AddEntry(f1, "During day & night", "l");
    TF1* f2 = new TF1(*f1);
    f2->SetParameter(1,ObsFTot);
    f2->SetLineColor(3);
    f2->Draw("SAME");
    leg->AddEntry(f2, "During total observation time", "l");
    TF1* f3 = new TF1(*f1);
    f3->SetParameter(1,ObsFGod);
    f3->SetLineColor(4);
    f3->Draw("SAME");
    leg->AddEntry(f3, "During good observational conditions", "l");
      
    leg->Draw();    
}

What I mean is the red function graph that is drawn on the upper border of the visible area when the graph hits this border.

see a solution below

Rene

[code]{
float ObsFTot = 1835/(365.0 * 24);
float ObsFGod = 1086/(365.0 * 24);
float ClearSkyF = 0.6;
float WMax = 60;
float GRBpAnno = 300 / 3.2;
TCanvas* c = new TCanvas(“angular_dist”,“Tracking Duration”,0,0,800,600);
TF1* f1 = new TF1(“angular”,"[0] * [1] * 2pi(1-cos(x * pi/180.0)) / (4*pi)",0,WMax);
TLegend leg = new TLegend(0.6, 0.83, 0.89, 0.89);
leg->SetFillColor(0);
c->cd(1);
c->SetTickx();
c->DrawFrame(0,0,60,3.5); //<==========
f1->SetParameter(0,GRBpAnno);
f1->SetParameter(1,1);
f1->SetTitle(“Annual GRBs within an angular offset”);
f1->GetXaxis()->SetTitle(“Angular offset in deg”);
f1->GetYaxis()->SetTitle(“Annual GRBs”);
f1->GetXaxis()->CenterTitle();
f1->GetYaxis()->CenterTitle();
f1->GetXaxis()->SetRangeUser(0,WMax);
//f1->GetYaxis()->SetRangeUser(0,3.5); //<==========
f1->SetMaximum(3.501); //<==========
f1->SetLineColor(2);
f1->SetLineWidth(1);
f1->Draw(“same”); //<==========
leg->AddEntry(f1, “During day & night”, “l”);
TF1
f2 = new TF1(f1);
f2->SetParameter(1,ObsFTot);
f2->SetLineColor(3);
f2->Draw(“SAME”);
leg->AddEntry(f2, “During total observation time”, “l”);
TF1
f3 = new TF1(*f1);
f3->SetParameter(1,ObsFGod);
f3->SetLineColor(4);
f3->Draw(“SAME”);
leg->AddEntry(f3, “During good observational conditions”, “l”);

leg->Draw(); 

}
[/code]

Thank you, I will try that. Can someone tell me why this is the standard behavior of ROOT TF1s? Maybe at least a switch should be implemented to turn it off…

Unfortunately, the above suggestion does not work either. When I Draw() the first function with the option SAME, I loose my axes labels. When I don’t do it, the second function (green) is now extended on the border.

Any more suggestions?

Are you really running my script? It looks like you miss the statement 'c->DrawFrame(…)"

Rene