2
$\begingroup$

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):

http://wstaw.org/m/2011/12/23/m51.png

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.

http://wstaw.org/m/2011/12/23/m52.png

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.

  • 2
    Your question is quite off-topic in this site. You should be asking in some ROOT mailing list or something similar.2011-12-31

1 Answers 1

1

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"); } 
  • 0
    Oh, that is good to know. Thanks!2012-01-01