Re: [ROOT] TPad::SetLogx() does not work on TMarker

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Jul 20 2000 - 10:20:08 MEST


Hello Aihong,

The low level primitives like TLine, TMarker use directly the current
pad range. Only higher level primitives such as TGraph, TH1xx accept
in addition lin/log scales. 

As already reported by Michal, you can use the class TGraph to visualize
a set of markers, lines or combination in lin/log scales.

As an alternative, you can also change your line
     TMarker* mk = new TMarker(i,i,20);
to
     TMarker* mk = new TMarker(c1->XtoPad(i),c1->YtoPad(i),20);


The TPad::XtoPad will make the transformation lin/log if a log scale
has been selected along x or/and y.

Using these functions, you do not need to change your macro if you switch
between lin and log scales. You only have to reexecute the macro.

One could imagine to do this conversion automatically inside the low level
primitives Paint functions, but this requires a bit more work, could introduce
some backward incompatibility and also a performance penalty.

Rene Brun

Aihong Tang wrote:
> 
> Hi,
> 
> I am trying to insert TMarker into histogram and draw with logx axis. The
> following code shows that SetLogx() does  not work with TMarker.
> 
> void logTest(){
>   TCanvas* c1= new TCanvas("c1");
>   c1->SetLogx(1);
>   c1->Draw();
>   c1->cd();
> 
>   TH1F* h1 = new TH1F ("h1","h1",10,0,10);
>   h1->SetMaximum(11);
> 
>   for (Int_t i=0; i<10; i++) {
>      TMarker* mk = new TMarker(i,i,20);
>      h1->GetListOfFunctions()->Add(mk);
>   }
> 
>   h1->Draw("AP");
>   c1->Update();
> }
> 
> I admitt that there is a work around for this purpose by SetBinContent()
> and draw the histogram, but in my analysis code I have to use TMarker.
> 
> Thank you for any help.
> 
> Aihong
> P.S. I am using ROOT_LEVEL : 2.25.00  on linux machine.



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:30 MET