[SOLVED]Several Functions

Dear forum,
I am trying to Draw() several functions… The code of the functions is:
TF1 f2 = new TF1 (“f2”, "2 + 2x", 0, 2);
TF1 *f3 = new TF1 (“f3”, “6”, 2, 5);
TF1 f4 = new TF1 (“f4”, "-5x+31", 5, 7);
TF1 *f5 = new TF1 (“f5”, “-4”, 7, 9);
TF1 f6 = new TF1 (“f6”, "-2x+14", 9, 1);

I would like to ask you, how I can draw them on the same canvas? As you can see, each one continuity of the other…
I tried
f2->Draw();
f3->Draw(“same”);
f4->Draw(“same”);
f5->Draw(“same”);
f6->Draw(“same”);
but obviously, the problem is about X axis range…
I also tried
f2->GetXaxis()->SetRangeUser(0, 12), but no results… It doesn’t change the axis range…

Instead of:
f2->Draw();
try:
TCanvas *c = new TCanvas(“c”, “c”);
c->DrawFrame(0, -5, 9, 13, “multi function plot”); // xmin, ymin, xmax, ymax, title
f2->Draw(“same”);

Thank you so much Pepe… :slight_smile:
And another one question…
Is there any way to add titles on the axis? Something like GetXaxis()->SetTitle("")

Thank you in advance

TCanvas *c = new TCanvas("c", "c"); c->DrawFrame(0, -5, 9, 13, "multi function plot"); // xmin, ymin, xmax, ymax, title c->Update(); // make sure it's really drawn TH1F *h = ((TH1F *)(c->GetListOfPrimitives()->FindObject("hframe"))); if (h) { h->SetXTitle("x title"); // x-axis title h->SetYTitle("y title"); // y-axis title } c->Update(); // make sure it's re-drawn

thank you so much Pepe :smiley: