Re: [ROOT] TGaxis with function

From: Olivier Couet (Olivier.Couet@cern.ch)
Date: Thu Mar 11 2004 - 10:04:57 MET


 Hi Tommaso,

 I see your point. You would like that the axis labels change according to 
the function, isn't it ? This not how this feature is working. In fact is 
works exactly the same as the Logy and Logx options: When you "set on" one 
of these options, the axis tick marks are positioned according to a log 
scale but the axis labels keep their "linear values". So when you use a 
function to create an axis, the tick marks will be positioned according to 
this function but the axis labels will keep their "linear values". 
Therefore adding or subtracting a constant has no visible effect, because 
it just performs a translation of a linear scale so it remains linear. I 
have attached a little macro creating a few axis showing this.

 Cheers,       Olivier



On Wed, 10 Mar 2004, Tommaso Chiarusi wrote:

> Ok, the algorithm is simply
> fu = 90 -x[0];
> 
> But the substance of the problem does not change: with this function
> the range is not modified as I wanted...
> 
> 
> ok...
> On Wed, 10 Mar 2004, Olivier Couet wrote:
> 
> > 
> > 
> > 
> > Hi Tommaso,
> > 
> >  are you sure that the real algorithm is:
> > 
> >      if(x[0]<=90) fu = 90 - x[0];
> >      else fu = 90-x[0];
> > 
> >  ??
> > 
> >  because seems to me these two lines are the same as:
> > 
> >  fu = 90-x[0];
> > 
> >  Cheers,        Olivier
> > 
> > 
> > On Wed, 10 Mar 2004, Tommaso Chiarusi wrote:
> > 
> > > Hi Olivier,
> > > you were right, I made a mistake, in fact the real algorithm is
> > > 
> > >     if(x[0]<=90) fu = 90 - x[0];
> > >     else fu = 90-x[0]; 
> > > 
> > > and not 
> > >     else fu = x[0]-270; 
> > > 
> > > Well yesterday I fused...:) 
> > > 
> > > 
> > > buy the way the devicing fact is that, neither with the 
> > > correct algorithm, the labels on to  the plot are not modified 
> > > accordingly!!!
> > > In fact I get simply 
> > > 180 160 140 120 100 80 60 40 20 0
> > > 
> > > Moreover, if in the function you set:
> > >       fu = x[0]*2;
> > > 
> > > just for trying, you get no effect on the range.
> > > 
> > > may be I didn't well understand how TGaxis works with a function.
> > > 
> > > any suggestion?
> > > Thank you.
> > > Tommaso
> > > 
> > > On Wed, 10 Mar 2004, Olivier Couet wrote:
> > > 
> > > > 
> > > > Hi Tommaso,
> > > > 
> > > >  I looked closer at your examples. I agree with you that the first one 
> > > > transform the following labels:
> > > > 
> > > > -80 -60 -40 -20  0  20  40  60  80
> > > > 
> > > > into:
> > > > 
> > > >  80  60  40  20  0 -20 -40 -60 -80
> > > > 
> > > > But, seems to me the 2nd example transform:
> > > >  
> > > >   0  20  40  60  80  100  120  140  160 180
> > > > 
> > > > into:
> > > > 
> > > >  90  70  50  30  10 -170 -150 -130 -110 -90
> > > > 
> > > >  Which, I guess, is not what you want. I think you did a mistake in your 
> > > > 2nd example.
> > > > 
> > > >  Cheers,      Olivier
> > > > 
> > > > 
> > > > On Tue, 9 Mar 2004, Tommaso Chiarusi wrote:
> > > > 
> > > > > 
> > > > > Hello everybody:
> > > > > 
> > > > > OS Linux RH 9
> > > > > ROOT 3.10/02  16 December 2003
> > > > > 
> > > > > well, I need to reset the labels onto an histogram.
> > > > > It has the x axis which ranges from 0 to +180
> > > > > I like it to span from +90 to -90 (yes from positive to negative
> > > > > like 90 80 70..10 0 -10 ... -80 -90).
> > > > > 
> > > > > So decided to  
> > > > > TGaxis method together with a function
> > > > > 
> > > > > 
> > > > > So I've written the function:
> > > > > 
> > > > > double funz(double *x,double *par)
> > > > > {
> > > > >   double fu=0;
> > > > >   fu = -x[0];
> > > > >   return fu;
> > > > > }
> > > > > 
> > > > > and in the body of the macro, 
> > > > > 
> > > > >  TF1 *f = new TF1("f",funz,-90,90,0);
> > > > >  TGaxis *tga = new TGaxis(0,0,180,0,"f",510);
> > > > >  tga->Draw();
> > > > > 
> > > > > and it works!
> > > > > 
> > > > > note that the spanning of the new scale is independent from the original
> > > > > range.
> > > > > -----
> > > > > THE QUESTION:
> > > > > 
> > > > > Why the following doesn't give the same result?
> > > > > 
> > > > > I redefine the function,
> > > > > 
> > > > > double funz(double *x,double *par)
> > > > > {
> > > > >   double fu=0;
> > > > >   if(x[0]<=90) fu = 90 -x[0];
> > > > >   if(x[0]>90) fu = x[0]-270;
> > > > > 
> > > > >   return fu;
> > > > > }
> > > > >                                                                                                  
> > > > > and in the body of the macro,
> > > > >                                                                                                  
> > > > >  TF1 *f = new TF1("f",funz,0,180,0);
> > > > >  TGaxis *tga = new TGaxis(0,0,180,0,"f",510);
> > > > >  tga->Draw();
> > > > > 
> > > > > note the different range for f
> > > > > 
> > > > > Best regards, Tommaso
> > > > > 
> > > > > P.S.
> > > > > is this mailing list hard-contamined by spam?
> > > > > is it true that it will be removed by the CERN mailing list?
> > > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > 
> > > > 
> > > 
> > > 
> > 
> > 
> 
> 

-- 
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:06 MET