TMultiGraph does not inherit TGraph properties

Hello

I am trying to put two TGraphs via TMultiGraph. Both fo the TGraphs have set to have the same range. However, the Mutligraph is not waht is expected ie only one of the TGraphs is shown and also no correct range, labels etc…



  TCanvas *c1=new TCanvas("can1","CANVAS-SCAN1D",800,800);
  c1->cd();
  gr0->GetXaxis()->SetTitle("f_{A}");
  gr0->GetYaxis()->SetTitle("-2 #Delta lnL");
  gr0->GetYaxis()->SetTitleOffset(3);
  gr0->GetYaxis()->SetTitleOffset(1);
  gr0->GetXaxis()->SetLabelSize(0.04);
  gr0->GetYaxis()->SetLabelSize(0.03);
  gr0->GetYaxis()->SetRangeUser(0.,7);
  gr0->GetXaxis()->SetRangeUser(-1,1.);

  gr_et_exp->GetXaxis()->SetTitle("f_{A}");
  gr_et_exp->GetYaxis()->SetTitle("-2 #Delta lnL");
  gr_et_exp->GetYaxis()->SetTitleOffset(3);
  gr_et_exp->GetYaxis()->SetTitleOffset(1);
  gr_et_exp->GetXaxis()->SetLabelSize(0.04);
  gr_et_exp->GetYaxis()->SetLabelSize(0.03);
  gr_et_exp->GetYaxis()->SetRangeUser(0.,7);
  gr_et_exp->GetXaxis()->SetRangeUser(-1,1.);

  TMultiGraph *mg = new TMultiGraph();
  mg->Add(gr_et_exp);
  mg->Add(gr0);
  mg->Draw("AC");

Screen Shot 2018-07-07 at 13.23.48.pdf (284.6 KB)

You need to make all these changes to the TMultiGraph (not to individual graphs).

it gives a segmentation fault and crashes…


  TTree *t=(TTree*)f->Get("limit");
  t->Draw("2*deltaNLL:CMS_zz4l_fai1");
  TGraph *gr0 = (TGraph*) gROOT->FindObject("Graph")->Clone();

  TTree *t_exp_et=(TTree*)f_exp_et->Get("limit");
  t_exp_et->Draw("2*deltaNLL:CMS_zz4l_fai1");
  TGraph *gr_et_exp = (TGraph*) gROOT->FindObject("Graph")->Clone();

  gr0->SetLineColor(kRed);
  gr_et_exp->SetLineColor(kRed);

  TCanvas *c1=new TCanvas("can1","CANVAS-SCAN1D",800,800);

  TMultiGraph *mg = new TMultiGraph();
  c1->cd();
  mg->GetXaxis()->SetTitle("f_{a3}cos(#phi_{a3})");
  mg->GetYaxis()->SetTitle("-2 #Delta lnL");
  mg->GetYaxis()->SetTitleOffset(3);
  mg->GetYaxis()->SetTitleOffset(1);
  mg->GetXaxis()->SetLabelSize(0.04);
  mg->GetYaxis()->SetLabelSize(0.03);
  mg->GetYaxis()->SetRangeUser(0.,7);
  mg->GetXaxis()->SetRangeUser(-1,1.);
  mg->Add(gr_et_exp);
  mg->Add(gr0);
  mg->Draw("AC");
TMultiGraph *mg = new TMultiGraph();
mg->Add(gr_et_exp);
mg->Add(gr0);
mg->Draw("AC");
gPad->Modified(); gPad->Update(); // make sure it is really (re)drawn
// ... modify what you want here ...
gPad->Modified(); gPad->Update(); // make sure it is really (re)drawn
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.