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.