#include #include #include #include #include #include void Example(){ TGraph *g1 = new TGraph(); TGraph *g2 = new TGraph(); TGraph *g3 = new TGraph(); TCanvas *ccc = new TCanvas(); Int_t i; for(i=0;i<10;i++){ g1->SetPoint(i,i,i%3); g2->SetPoint(i,i,i%4); g3->SetPoint(i,i,i%2); } ccc->Clear(); g1->SetMarkerStyle(20); g2->SetMarkerStyle(21); g3->SetMarkerStyle(22); g1->SetMarkerColor(2); g2->SetMarkerColor(3); g3->SetMarkerColor(4); TLegend * leg = new TLegend(0.6,0.85,0.95,1); leg->AddEntry(g1,"1"); leg->AddEntry(g2,"1"); leg->AddEntry(g3,"3"); TMultiGraph *ggg = new TMultiGraph("Esempio","Esempio"); ggg->Add(g1); ggg->Add(g2); ggg->Add(g3); TF1 *ppp = new TF1("ppp","pol0"); gStyle->SetOptFit(1111); ggg->SetTitle("Esempio"); ggg->Draw("AP"); ggg->Fit(ppp,"V"); //uncomment this to see th workaround I used /* char stt[80]; sprintf(stt,"Chisquare/NDF: %f/%d",ppp->GetChisquare(),ppp->GetNDF()); leg->AddEntry(ppp,stt); leg->Draw(); */ }