Re: [ROOT] How to draw a TMarker at a given position

From: Olivier Couet (Olivier.Couet@cern.ch)
Date: Tue Apr 13 2004 - 14:57:34 MEST


Yes, actually I was also surprised to see something with CONT4 because this 
option uses a 3D algorithm to draw the contour and the Pad coordinates are 
in some sort of normalized 3D coordinates which do not correspond to the 
2D coordinates you see. Any other 2D option works properly:

{
TFile f("hsimple.root");
hpxpy->Draw("cont1"); // try also COL, BOX, TEXT CONT2, etc etc ...
TMarker *m = new TMarker(1.0, 1.5, 29);
m->Draw();
}

It was bad luck to have chosen these coordinates which appeared to "almost 
work" sorry for that. So I would recommend you to use an other option to 
draw the contour (to keep you macro simple).

To have the marker coordinate in the "CONT4 space" it is a be more tricky. 
You should do something like:

{
TFile f("hsimple.root");
hpxpy->Draw("cont4");
gPad->Update();
TView *view = gPad->GetView();
Double_t xyz1[3] = {1.0,3,1.};  
Double_t xyz2[3];
view->WCtoNDC(xyz1, xyz2);     
TMarker *m = new TMarker(xyz2[0], xyz2[1], 29);
m->Draw();
}


 Cheers, Olivier

On Tue, 13 Apr 2004, Jacek M. Holeczek wrote:

> Hi,
> 
> Today in the morning I also had the idea that I should first draw
> everything in linear scale and then SetLog axes ...
> Well, i just finished my test (sorry, it takes about 3 hours to fill
> histograms) ... the outcome is ... it doesn't work ...
> 
> > For me it works. I tried the following example:
> 
> Well, it doesn't really ...
> 
> I repeated your "test" line by line (4.00.03, gcc-3.2.3, RH7.3) ...
> 
> >    TFile f("hsimple.root");
> 
> I take to file "hsimple.root" created by tutorials/hsimple.C ...
> 
> >    hpxpy->Draw("cont4");
> 
> The histogram is drawn with linear X and Y axes ...
> 
> >    TMarker *m = new TMarker(1.0, 1.5, 29);
> >    m->Draw();
> 
> NO MARKER PRESENT IN MY CANVAS !!!!
> The canvas looks exactly like it was before "m->Draw();" ...
> 
> >    gPad->SetLogx(kTRUE);
> >    gPad->SetLogy(kTRUE);
> > }
> >
> > and I get the attached result
> 
> I get exactly the same picture as you in the postscript file ...
> Both axes are Log now ...
> Surprise ... the marker is visible now ...
> But ... the position is INCORRECT ...
> Note that ... it's clearly visible that ... X=0.9, Y=1.4 ... while you
> asked X=1., Y=1.5 !!!!
> 
> Best regards,
> Jacek.
> 
> P.S. Just to add something, in my picture I would like to get the marker
>      at (1.0, 0.0001). I discovered that I need to create it at (1.6, 1.0)
>      and then it is more or less in the required position (note also that
>      (log10(1.0), log10(0.0001)) does NOT help). Moreover, changing axes
>      between log and linear ... makes the marker disappear and/or changes
>      it's position in the picture. Jacek.
> 
> 

-- 
Org:    CERN - European Laboratory for Particle Physics.
Mail:   1211 Geneve 23 - Switzerland                     Mailbox: J25910      
E-Mail: Olivier.Couet@cern.ch                            Phone:   +41 22 7676522
WWW:    http://cern.ch/Olivier.Couet/                    Fax:     +41 22 7677155



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET