TGaxis


class description - source file - inheritance tree

class TGaxis : public TLine, public TAttText


    public:
TGaxis TGaxis() TGaxis TGaxis(Float_t xmin, Float_t ymin, Float_t xmax, Float_t ymax, Float_t wmin, Float_t wmax, Int_t ndiv = 510, Option_t* chopt, Float_t gridlength = 0) TGaxis TGaxis(Float_t xmin, Float_t ymin, Float_t xmax, Float_t ymax, const char* funcname, Int_t ndiv = 510, Option_t* chopt, Float_t gridlength = 0) TGaxis TGaxis(TGaxis&) virtual void ~TGaxis() virtual void AdjustBinSize(Float_t A1, Float_t A2, Int_t nold, Float_t& BinLow, Float_t& BinHigh, Int_t& nbins, Float_t& BinWidth) virtual void CenterTitle(Bool_t center = kTRUE) TClass* Class() virtual void DrawAxis(Float_t xmin, Float_t ymin, Float_t xmax, Float_t ymax, Float_t wmin, Float_t wmax, Int_t ndiv = 510, Option_t* chopt, Float_t gridlength = 0) TF1* GetFunction() Float_t GetGridLength() Int_t GetLabelFont() Float_t GetLabelOffset() Float_t GetLabelSize() virtual const char* GetName() const Int_t GetNdiv() virtual const char* GetOption() const Float_t GetTickSize() virtual const char* GetTitle() const Float_t GetTitleOffset() Float_t GetTitleSize() Float_t GetWmax() Float_t GetWmin() virtual TClass* IsA() const void LabelsLimits(char* label, Int_t& first, Int_t& last) virtual void Optimize(Float_t A1, Float_t A2, Int_t nold, Float_t& BinLow, Float_t& BinHigh, Int_t& nbins, Float_t& BWID) virtual void Paint(Option_t* chopt) virtual void PaintAxis(Float_t xmin, Float_t ymin, Float_t xmax, Float_t ymax, Float_t& wmin, Float_t& wmax, Int_t& ndiv, Option_t* chopt, Float_t gridlength = 0) virtual void Rotate(Float_t X, Float_t Y, Float_t CFI, Float_t SFI, Float_t XT, Float_t YT, Float_t& U, Float_t& V) virtual void SavePrimitive(ofstream& out, Option_t* option) void SetFunction(const char* funcname) void SetGridLength(Float_t gridlength) void SetLabelFont(Int_t labelfont) void SetLabelOffset(Float_t labeloffset) void SetLabelSize(Float_t labelsize) virtual void SetName(char* name) void SetOption(Option_t* option) void SetTickSize(Float_t ticksize) void SetTimeFormat(const char* tformat) virtual void SetTitle(const char* title) void SetTitleOffset(Float_t titleoffset = 1) void SetTitleSize(Float_t titlesize) void SetWmax(Float_t wmax) void SetWmin(Float_t wmin) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Streamer(TBuffer& b)

Data Members

protected:
Int_t fNdiv Number of divisions Float_t fWmin Lowest value on the axis Float_t fWmax Highest value on the axis Float_t fGridLength Length of the grid in NDC Float_t fTickSize Size of primary tick mark in NDC Float_t fLabelOffset Offset of label wrt axis Float_t fLabelSize Size of labels in NDC Float_t fTitleOffset Offset of title wrt axis Float_t fTitleSize Size of title in NDC Int_t fLabelFont Font for labels TString fChopt Axis options TString fName axis name TString fTitle axis title TString fTimeFormat Time format, ex: 09/12/99 12:34:00 TString fFunctionName name of mapping function pointed by fFunction TF1* fFunction !Pointer to function computing axis values public:
static const enum TObject:: kCenterTitle

Class Description

 Service class for the graphical representation of axis.
 Instances of this class are generated by the histogram classes and TGraph.

 The picture below has been generated by the following macro.
{

  gROOT.Reset();

  c1 = new TCanvas("c1","Examples of Gaxis",10,10,700,500);

  c1->Range(-10,-1,10,1);

  TGaxis *axis1 = new TGaxis(-5,-0.2,6,-0.2,-6,8,510,"");
  axis1->SetName("axis1");
  axis1->Draw();

  TGaxis *axis2 = new TGaxis(-5,0.2,6,0.2,0.001,10000,510,"G");
  axis2->SetName("axis2");
  axis2->Draw();

  TGaxis *axis3 = new TGaxis(-9,-0.8,-9,0.8,-8,8,50510,"");
  axis3->SetName("axis3");
  axis3->Draw();

  TGaxis *axis4 = new TGaxis(-7,-0.8,-7,0.8,1,10000,50510,"G");
  axis4->SetName("axis4");
  axis4->Draw();

  TGaxis *axis5 = new TGaxis(-5,-0.6,6,-0.6,1.2,1.32,80506,"-+");
  axis5->SetName("axis5");
  axis5->SetLabelSize(0.03);
  axis5->SetTextFont(72);
  axis5->SetLabelOffset(0.025);

  axis5->Draw();

  TGaxis *axis6 = new TGaxis(-5,0.6,6,0.6,100,900,50510,"-");
  axis6->SetName("axis6");
  axis6->Draw();

  TGaxis *axis7 = new TGaxis(8,-0.8,8,0.8,0,9000,50510,"+L");
  axis7->SetName("axis7");
  axis7->SetLabelOffset(0.01);
  axis7->Draw();
}

/*

*/



  See the second TGaxis constructor for examples of TGaxis
  with a mapping function.

TGaxis(): TLine(), TAttText(11,0,1,62,0.040)
*-*-*-*-*-*-*-*-*-*-*Gaxis default constructor-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*                  =========================

TGaxis(Float_t xmin, Float_t ymin, Float_t xmax, Float_t ymax, Float_t wmin, Float_t wmax, Int_t ndiv, Option_t *chopt, Float_t gridlength) : TLine(xmin,ymin,xmax,ymax), TAttText(11,0,1,62,0.040)
*-*-*-*-*-*-*-*-*-*-*Gaxis normal constructor-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*                  =========================
  See explanation of parameters in PaintAxis


TGaxis(Float_t xmin, Float_t ymin, Float_t xmax, Float_t ymax, const char *funcname, Int_t ndiv, Option_t *chopt, Float_t gridlength) : TLine(xmin,ymin,xmax,ymax), TAttText(11,0,1,62,0.040)
*-*-*-*-*-*-*-*-*-*-*Gaxis constructor with a TF1 to map axis values-*-*-*
*-*                  ===============================================
  See explanation of parameters in PaintAxis
  Instead of the wmin,wmax arguments of the normal constructor, the
  name of a TF1 function can be specified. This function will be used
  by TGaxis::PaintAxis to map the user coordinates to the axis values
  and ticks.
  Examples:
void gaxis3a()
{
   gStyle->SetOptStat(0);

   TH2F *h2 = new TH2F("h","Axes",2,0,10,2,-2,2);
   h2->Draw();

   TF1 *f1=new TF1("f1","-x",-10,10);
   TGaxis *A1 = new TGaxis(0,2,10,2,"f1",510,"-");
   A1->SetTitle("axis with decreasing values");
   A1->Draw();

   TF1 *f2=new TF1("f2","exp(x)",0,2);
   TGaxis *A2 = new TGaxis(1,1,9,1,"f2");
   A2->SetTitle("exponential axis");
   A2->SetLabelSize(0.03);
   A2->SetTitleSize(0.03);
   A2->SetTitleOffset(1.2);
   A2->Draw();

   TF1 *f3=new TF1("f3","log10(x)",0,800);
   TGaxis *A3 = new TGaxis(2,-2,2,0,"f3",505);
   A3->SetTitle("logarithmic axis");
   A3->SetLabelSize(0.03);
   A3->SetTitleSize(0.03);
   A3->SetTitleOffset(1.2);
   A3->Draw();
}

/*

*/


~TGaxis()
*-*-*-*-*-*-*-*-*-*-*Gaxis default destructor-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*                  =======================

void CenterTitle(Bool_t center)
   if center = kTRUE axis title will be centered
   default is right adjusted

void DrawAxis(Float_t xmin, Float_t ymin, Float_t xmax, Float_t ymax, Float_t wmin, Float_t wmax, Int_t ndiv, Option_t *chopt, Float_t gridlength)
*-*-*-*-*-*-*-*-*-*-*Draw this axis with new attributes*-*-*-*-*-*-*-*-*-*
*-*                  ==================================

void Paint(Option_t *)
*-*-*-*-*-*-*-*-*-*-*Draw this axis with its current attributes*-*-*-*-*-*-*
*-*                  ==========================================

void PaintAxis(Float_t xmin, Float_t ymin, Float_t xmax, Float_t ymax, Float_t &wmin, Float_t &wmax, Int_t &ndiv, Option_t *chopt, Float_t gridlength)
*-*-*-*-*-*-*-*-*-*-*-*Control function to draw an axis*-*-*-*-*-*-*-*-*-*-*
*-*                    ================================

============> Original authors (O.Couet C.E.Vandoni N.Cremel-Somon)
              largely modified and converted to C++ class by Rene Brun

 _Input parameters:

  xmin      : X origin coordinate in WC space.
  xmax      : X end axis coordinate in WC space.
  ymin      : Y origin coordinate in WC space.
  ymax      : Y end axis coordinate in WC space.
  wmin      : Lowest value for the tick mark
              labels written on the axis.
  wmax      : Highest value for the tick mark labels
              written on the axis.
  ndiv      : Number of divisions.

       ndiv=N1 + 100*N2 + 10000*N3
       N1=number of 1st divisions.
       N2=number of 2nd divisions.
       N3=number of 3rd divisions.
           e.g.:
           nndi=0 --> no tick marks.
           nndi=2 --> 2 divisions, one tick mark in the middle
                      of the axis.

  chopt :  Options (see below).

       chopt='G': loGarithmic scale, default is linear.
       chopt='B': Blank axis. Useful to superpose axis.

 Orientation of tick marks on axis.
 ----------------------------------

   Tick marks are normally drawn on the positive side of the axis,
   however, if X0=X1, then negative.

       chopt='+': tick marks are drawn on Positive side. (default)
       chopt='-': tick mark are drawn on the negative side.
       i.e: '+-' --> tick marks are drawn on both sides of the axis.
       chopt='U': Unlabeled axis, default is labeled.

 Position of labels on axis.
 ---------------------------

   Labels are normally drawn on side opposite to tick marks.
   However:

       chopt='=': on Equal side

 Orientation of labels on axis.
 ------------------------------

   Labels are normally drawn parallel to the axis.
   However if X0=X1, then Orthogonal
           if Y0=Y1, then Parallel

 Position of labels on tick marks.
 ---------------------------------

   Labels are centered on tick marks.
   However , if X0=X1, then they are right adjusted.

       chopt='R': labels are Right adjusted on tick mark.
                    (default is centered)
       chopt='L': labels are Left adjusted on tick mark.
       chopt='C': labels are Centered on tick mark.
       chopt='M': In the Middle of the divisions.

 Format of labels.
 -----------------

   Blank characters are stripped, and then the
   label is correctly aligned. the dot, if last
   character of the string, is also stripped.

   In the following, we have some parameters, like
   tick marks length and characters height (in percentage
   of the length of the axis (WC))
   The default values are as follows:

   Primary tick marks: 3.0 %
   Secondary tick marks: 1.5 %
   Third order tick marks: .75 %
   Characters height for labels: 4%

   Labels offset: 1.0 %

 Optional grid.
 --------------

       chopt='W': cross-Wire

 Axis bining optimization.
 -------------------------

   By default the axis bining is optimized .

       chopt='N': No bining optimization
       chopt='I': Integer labelling


 Time representation.
 --------------------

   Axis labels may be considered as times, plotted in
   a defined time format. The format id set with SetTimeFormat().

       chopt='t': Plot times with a defined format instead of values


void Optimize(Float_t A1, Float_t A2, Int_t nold ,Float_t &BinLow, Float_t &BinHigh, Int_t &nbins, Float_t &BinWidth)
*-*-*-*-*-*-*-*-*-*-*-*Reasonable Axis labels optimisation*-*-*-*-*-*-*-*-*
*-*                    ===================================
*-*  Get reasonable values for tick marks & ensure they are
*-*  not plotted beyond allowed limits
*-*
*-* _Input parameters:
*-*
*-*  A1,A2 : Old WMIN,WMAX .
*-*  BinLow,BinHigh : New WMIN,WMAX .
*-*  nold   : Old NDIV .
*-*  nbins    : New NDIV .
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

void AdjustBinSize(Float_t A1, Float_t A2, Int_t nold ,Float_t &BinLow, Float_t &BinHigh, Int_t &nbins, Float_t &BinWidth)
*-*-*-*-*-*-*-*-*-*-*-*Axis labels optimisation*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*                    ========================

   This routine adjusts the bining of the axis
   in order to have integer values for the labels

 _Input parameters:

  A1,A2    : Old WMIN,WMAX .
  BinLow,BinHigh : New WMIN,WMAX .
  nold     : Old NDIV (primary divisions)
  nbins    : New NDIV .


void LabelsLimits(char *label, Int_t &first, Int_t &last)
*-*-*-*-*-*-*-*-*Find first and last character of a label*-*-*-*-*-*-*-*-*-*
*-*              ========================================

void Rotate(Float_t X, Float_t Y, Float_t CFI, Float_t SFI ,Float_t XT, Float_t YT, Float_t &U, Float_t &V)
*-*-*-*-*-*-*-*-*-*-*-*-*-*Rotate axis coordinates*-*-*-*-*-*-*-*-*-*-*-*-*
*-*                        =======================

void SavePrimitive(ofstream &out, Option_t *)
 Save primitive as a C++ statement(s) on output stream out

void SetFunction(const char *funcname)
        specify a function to map the axis values
        =========================================

void SetName(char *name)
*-*-*-*-*-*-*-*-*-*-*Change the name of the axis*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*                  ============================

void SetOption(Option_t *option)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*To set axis options*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-*                          ===================

void SetTitle(const char *title)
*-*-*-*-*-*-*-*-*-*-*Change the title of the axis*-*-*-*-*-*-*-*-*-*-*-*-*
*-*                  ============================

void SetTimeFormat(const char *tformat)
*-*-*-*-*-*-*-*-*-*-*Change the format used for time plotting *-*-*-*-*-*-*-*
*-*                  ========================================
  The format string for date and time use the same options as the one used
  in the standard strftime C function, i.e. :
    for date :
      %a abbreviated weekday name
      %b abbreviated month name
      %d day of the month (01-31)
      %m month (01-12)
      %y year without century

    for time :
      %H hour (24-hour clock)
      %I hour (12-hour clock)
      %p local equivalent of AM or PM
      %M minute (00-59)
      %S seconds (00-61)
      %% %

void Streamer(TBuffer &R__b)
 Stream an object of class TGaxis.



Inline Functions


            Float_t GetGridLength()
               TF1* GetFunction()
              Int_t GetLabelFont()
            Float_t GetLabelOffset()
            Float_t GetLabelSize()
            Float_t GetTitleOffset()
            Float_t GetTitleSize()
        const char* GetName() const
        const char* GetOption() const
        const char* GetTitle() const
              Int_t GetNdiv()
            Float_t GetWmin()
            Float_t GetWmax()
            Float_t GetTickSize()
               void SetLabelFont(Int_t labelfont)
               void SetLabelOffset(Float_t labeloffset)
               void SetLabelSize(Float_t labelsize)
               void SetTickSize(Float_t ticksize)
               void SetGridLength(Float_t gridlength)
               void SetTitleOffset(Float_t titleoffset = 1)
               void SetTitleSize(Float_t titlesize)
               void SetWmin(Float_t wmin)
               void SetWmax(Float_t wmax)
            TClass* Class()
            TClass* IsA() const
               void ShowMembers(TMemberInspector& insp, char* parent)
             TGaxis TGaxis(TGaxis&)


Author: Rene Brun, Olivier Couet 12/12/94
Last update: 2.23/12 26/01/2000 09.31.21 by Rene Brun
Copyright (c) 1995-1999, The ROOT System, All rights reserved. *


ROOT page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.