RE: TPad.BuildLegend()

From: Olivier Couet <Olivier.Couet_at_cern.ch>
Date: Tue, 22 Jun 2010 10:07:01 +0200


Of course my example has only one pad.
Your case is surely more complex (2 pads). I will try with 2 pads.
Note that the method BuildLegend does not refer to the current pad. I'll let you know.

-----Original Message-----

From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch] On Behalf Of Olivier Couet
Sent: Tuesday, June 22, 2010 10:01 AM
To: Vassili Maroussov; roottalk_at_root.cern.ch Subject: RE: [ROOT] TPad.BuildLegend()

I don't see the behavior you describe. Try the following example:

{

   TCanvas *c = new TCanvas("c","c",400, 600);

   const Int_t size = 10;

   double x[size];
   double y1[size];
   double y2[size];

   for ( int i = 0; i < size ; ++i ) {

      x[i] = i;
      y1[i] = size - i;
      y2[i] = size - 0.5 * i;

   }

   TGraph * gr1 = new TGraph( size, x, y1 );

   gr1->SetName("gr1");
   gr1->SetTitle("graph 1");
   gr1->SetMarkerStyle(21);
   gr1->SetDrawOption("AP");
   gr1->SetLineColor(2);
   gr1->SetLineWidth(4);
   gr1->SetFillStyle(0);
   gr1->SetFillColor(4);

   TGraph * gr2 = new TGraph( size, x, y2 );

   gr2->SetName("gr2");
   gr2->SetTitle("graph 2");
   gr2->SetMarkerStyle(22);
   gr2->SetMarkerColor(2);
   gr2->SetDrawOption("P");
   gr2->SetLineColor(3);
   gr2->SetLineWidth(4);
   gr2->SetFillStyle(0);

   gr1->Draw("ALP");
   gr2->Draw("LP");
   c->BuildLegend();

   c->Print("graphleg.gif");
   c->Print("graphleg.ps");
}

-----Original Message-----

From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch] On Behalf Of Vassili Maroussov
Sent: Tuesday, June 22, 2010 9:53 AM
To: roottalk_at_root.cern.ch
Subject: [ROOT] TPad.BuildLegend()

Dear ROOTers,

I've found that TPad.BuildLegend() is building the legend not in the object inherited from TPad, which is calling the method, but in the current TPad; so I have always to make TPad.cd() before TPad.BuildLegend(). Is it made intentionally?

Regards,

Vassili Received on Tue Jun 22 2010 - 10:07:05 CEST

This archive was generated by hypermail 2.2.0 : Tue Jun 22 2010 - 11:50:01 CEST