Re: Putting markers on a TGraph2D

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Sat, 16 May 2009 21:18:42 +0200


Hi Roger,

Simply do:

{

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

   TGraph2D *dt = new TGraph2D("graph.dat");

   dt->SetMarkerStyle(8);
   dt->SetMarkerSize(3);
   gStyle->SetPalette(1);
   dt->Draw("surf2");
   dt->Draw("CONT1 SAME p");

   return c;
}

Rene Brun

Roger Mason wrote:
> Hello,
>
> I am trying to put markes at specific positions on a TGraph2D. Here is
> the macro:
>
> {
> TCanvas *c = new TCanvas("c","Graph2D example",0,0,600,400);
>
> TGraph2D *dt = new TGraph2D("graph.dat");
>
> Int_t n = dt->GetN();
> Double_t* x = dt->GetX();
> Double_t* y = dt->GetY();
>
> TMarker* m = new TMarker();
>
> gStyle->SetPalette(1);
> dt->Draw("surf2");
> dt->Draw("CONT1 SAME");
>
> for (Int_t i = 0; i < n; i++ ){
> m = new TMarker(x[i],y[i],8);
> m->Draw("SAME");
> }
>
> return c;
> }
>
> graph.dat:
>
> 13 18 200
> 15 100 40
> 59 46 100
> 79 78 199
> 124 62 80
> 145 20 20
> 145 100 100
>
> I have tried a few variations. The TGraph2D is drawn correctly but the
> markers are never visible. If someone can tell me how to draw a point at a
> position on the surface drawn by TGraph2D I'd be most grateful.
>
> Thanks,
> Roger
>
> ROOT 5.20/00 (trunk_at_24524, Sep 30 2008, 15:32:00 on linux)
>
>
Received on Sat May 16 2009 - 21:19:09 CEST

This archive was generated by hypermail 2.2.0 : Sun May 17 2009 - 17:50:01 CEST