TGraph and TF1 in same pad

What I’m trying to do is plot a TGraph and a TF1(which is not the result of a fit) in the same pad, but in a way that the title of the graph is the one of the TGraph. I’ve tried several drawing options, and changed the order of drawing the two, but it looks like either only the TGraph is drawn or the title becomes that of the TF1.

for example

[code]TF1 *fa3 = new TF1(“fa3”,“TMath::Gaus(x,[0],[1],1)”,-5,5);
fa3->SetParameters(0,1);
fa3->Draw();

gsignals[i]->Draw("AP");[/code]

draws only the TGraph gsignals, while

gsignals[i]->Draw("AP");

TF1 *fa3 = new TF1("fa3","TMath::Gaus(x,[0],[1],1)",-5,5);
   fa3->SetParameters(0,1);
   fa3->Draw();

sets TMath::Gaus(… as the title. I tried to google it, but found no result. Does somebody know how I should do this?
Thank you

Try something like: // ... gsignals[i]->SetTitle( TString::Format("How do you like graph %i ?", i) ); gsignals[i]->Draw("AP"); // ... fa3->Draw("SAME"); gPad->Modified(); gPad->Update(); // ... See also:
TGraphPainter
TF1::Draw
TString::Format

[quote=“Wile E. Coyote”]Try something like: // ... gsignals[i]->SetTitle(TString::Format("How do you like graph %i ?", i)); gsignals[i]->Draw("AP"); // ... fa3->Draw("SAME"); gPad->Modified(); gPad->Update(); // ... See also:
TGraphPainter
TF1::Draw
TString::Format[/quote]

the “SAME” option plots the two of them indeed, and keeps the title of gsignals, but now the axis aren’t resized for fa3(which has slightly higher values) so that the uppermost parts of fa3 falls out of the border of the pad

// ... gsignals[i]->SetTitle(TString::Format("How do you like graph %i ?", i)); // ... gPad->Clear(); // just a precaution gPad->DrawFrame(fa3->GetXmin(), fa3->GetMinimum(), fa3->GetXmax(), fa3->GetMaximum(), gsignals[i]->GetTitle()); gsignals[i]->Draw("P SAME"); fa3->Draw("SAME"); gPad->Modified(); gPad->Update(); // ... See also:
TPad::DrawFrame

// ... Double_t xmin, xmax, ymin, ymax; // ... gsignals[i]->SetTitle(TString::Format("How do you like graph %i ?", i)); // ... xmin = gsignals[i]->GetXaxis()->GetXmin(); xmax = gsignals[i]->GetXaxis()->GetXmax(); ymin = gsignals[i]->GetYaxis()->GetXmin(); ymax = gsignals[i]->GetYaxis()->GetXmax(); if (xmin > fa3->GetXmin()) xmin = fa3->GetXmin(); if (xmax < fa3->GetXmax()) xmax = fa3->GetXmax(); if (ymin > fa3->GetMinimum()) ymin = fa3->GetMinimum(); if (ymax < fa3->GetMaximum()) ymax = fa3->GetMaximum(); gPad->Clear(); // just a precaution gPad->DrawFrame(xmin, ymin, xmax, ymax, gsignals[i]->GetTitle()); gsignals[i]->Draw("P SAME"); fa3->Draw("SAME"); gPad->Modified(); gPad->Update(); // ...

problem solved, thanks!