# Multiple plots in ROOT

I have some function with a parameter that I have to plot in ROOT into a single graph for different values of the parameter. It should look like this (made in Mathematica 8):

This is my current ROOT C++ code:

Double_t v(Double_t *t, Double_t *par) {
return par[1] * 10 / par[0] * (1-exp(-par[0]*t[0]/par[1]));
}

void draw() {
TCanvas *c = new TCanvas("c", "c", 800, 600);
c->cd(1);

TF1* fs[6];

fs[0] = new TF1("f0", v, 0, 10, 2);
fs[0]->SetParameters(0, 0.5);
fs[0]->SetParameters(1, 0.1);
fs[0]->Draw("same");

fs[1] = new TF1("f1", v, 0, 10, 2);
fs[1]->SetParameters(0, 0.5);
fs[1]->SetParameters(1, 0.2);
fs[1]->Draw("same");

fs[2] = new TF1("f2", v, 0, 10, 2);
fs[2]->SetParameters(0, 1.5);
fs[2]->SetParameters(1, 0.1);
fs[2]->Draw("same");

// More functions here ...
}


All I get is a plot with two graphs in it, but no axes and no labels.

If I do not use Draw("same") but just Draw(), I just get one of the functions, but in a nice plot.

How could I get all into one plot? The legend is a bonus.

-
Your question is quite off-topic in this site. You should be asking in some ROOT mailing list or something similar. –  Mariano Suárez-Alvarez Dec 31 '11 at 5:17

I just tried it again, with almost the same code and get the result I want. Strange …

{
TCanvas *c1 = new TCanvas("c1", "c1",30,113,800,600);
c1->Range(0,-10,60,600);

TF1 *f5 = new TF1("f5","sin(x)",0,6);

TF1 *f1 = new TF1("f1","cos(x)",0,6);
f5->Draw("");
f1->Draw("same");
}

-
The error you get comes from how ROOT TCanvas constructor is programmed. It uses the name to identify the TYPE of canvas it will create ... For example, if Canvas name starts with "gl" it will be ready to receive GL output. Completely moronic programming paradigm on part of ROOT. Which is why single character names are odd in ROOT. –  Ahmed Masud Jan 1 '12 at 15:06
Oh, that is good to know. Thanks! –  queueoverflow Jan 1 '12 at 16:00