RE: [ROOTDEV] TMultiGraph Axis

From: Olivier Couet <Olivier.Couet_at_cern.ch>
Date: Fri, 16 Apr 2010 16:26:39 +0200


Move:

mg->GetXaxis()->SetTitle("x");

After:

  mg->Draw("AC");

The axis does not exist before Draw()

-----Original Message-----
From: owner-rootdev_at_root.cern.ch [mailto:owner-rootdev_at_root.cern.ch] On Behalf Of Christian Hansen
Sent: Friday, April 16, 2010 4:11 PM
To: roottalk_at_root.cern.ch; roottalk
Subject: [ROOTDEV] TMultiGraph Axis

Dear Rooters,

My program crashes when I try to set the axis title of a TMultiGraph. Would anyone know why? An example code is attached and I use v5.26.

Best regards
/Christian

  TCanvas *c = new TCanvas("c","MultiGraph example",0,0,600,400);   Double_t x, y, z, P = 6.;
  Int_t np = 200;
  TMultiGraph *mg = new TMultiGraph();

  TGraph *gr1 = new TGraph();
  TGraph *gr2 = new TGraph();
  TRandom *r = new TRandom();

  for (Int_t N = 0; N < np; N++) {
    x = 2*r->Rndm(N);
    y = r->Rndm(N);
    gr1->SetPoint(N,x,y);
    gr2->SetPoint(N,2*x,2*y);
  }
  mg->Add(gr1);
  mg->Add(gr2);
  cout<<"Will set X Axis title"<<endl;
  mg->GetXaxis()->SetTitle("x"); // <-- chrashes here   cout<<"Set X Axis title"<<endl;
  mg->Draw("AC");
  c->Print("testMG.gif"); Received on Fri Apr 16 2010 - 16:27:13 CEST

This archive was generated by hypermail 2.2.0 : Sun Apr 18 2010 - 17:50:01 CEST