Logo ROOT  
Reference Guide
Go to the documentation of this file.
1// @(#)root/graf:$Id$
2// Author: Rene Brun, Olivier Couet 12/12/94
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
12#ifndef ROOT_TGaxis
13#define ROOT_TGaxis
15#include "TLine.h"
16#include "TAttText.h"
17#include "TString.h"
19class TF1;
20class TAxis;
21class TLatex;
23class TGaxis : public TLine, public TAttText {
27 Double_t fWmin; ///< Lowest value on the axis
28 Double_t fWmax; ///< Highest value on the axis
29 Float_t fGridLength; ///< Length of the grid in NDC
30 Float_t fTickSize; ///< Size of primary tick mark in NDC
31 Float_t fLabelOffset; ///< Offset of label wrt axis
32 Float_t fLabelSize; ///< Size of labels in NDC
33 Float_t fTitleOffset; ///< Offset of title wrt axis
34 Float_t fTitleSize; ///< Size of title in NDC
35 Int_t fNdiv; ///< Number of divisions
36 Int_t fLabelColor; ///< Color for labels
37 Int_t fLabelFont; ///< Font for labels
38 Int_t fNModLabs; ///< Number of modified labels
39 TString fChopt; ///< Axis options
40 TString fName; ///< Axis name
41 TString fTitle; ///< Axis title
42 TString fTimeFormat; ///< Time format, ex: 09/12/99 12:34:00
43 TString fFunctionName; ///< Name of mapping function pointed by fFunction
44 TF1 *fFunction; ///<! Pointer to function computing axis values
45 TAxis *fAxis; ///<! Pointer to original TAxis axis (if any)
46 TList *fModLabs; ///< List of modified labels.
48 TGaxis(const TGaxis&);
49 TGaxis& operator=(const TGaxis&);
51 Bool_t IsOwnedModLabs() const;
52 void CleanupModLabs();
56 TGaxis();
58 Double_t wmin,Double_t wmax,Int_t ndiv=510, Option_t *chopt="",
59 Double_t gridlength = 0);
61 const char *funcname, Int_t ndiv=510, Option_t *chopt="",
62 Double_t gridlength = 0);
63 virtual ~TGaxis();
65 virtual void AdjustBinSize(Double_t A1, Double_t A2, Int_t nold
66 ,Double_t &BinLow, Double_t &BinHigh, Int_t &nbins, Double_t &BinWidth);
67 virtual void CenterLabels(Bool_t center=kTRUE);
68 virtual void CenterTitle(Bool_t center=kTRUE);
69 void ChangeLabelAttributes(Int_t i, Int_t nlabels, TLatex* t, char* c);
71 Double_t wmin,Double_t wmax,Int_t ndiv=510, Option_t *chopt="",
72 Double_t gridlength = 0);
74 TF1 *GetFunction() const {return fFunction;}
76 Int_t GetLabelFont() const {return fLabelFont;}
81 const char *GetName() const override {return fName.Data();}
82 const char *GetOption() const override {return fChopt.Data();}
83 const char *GetTitle() const override {return fTitle.Data();}
84 static Int_t GetMaxDigits();
85 Int_t GetNdiv() const {return fNdiv;}
86 Double_t GetWmin() const {return fWmin;}
87 Double_t GetWmax() const {return fWmax;}
88 Float_t GetTickSize() const {return fTickSize;}
89 virtual void ImportAxisAttributes(TAxis *axis);
90 void LabelsLimits(const char *label, Int_t &first, Int_t &last);
91 void Paint(Option_t *chopt="") override;
93 Double_t &wmin,Double_t &wmax,Int_t &ndiv, Option_t *chopt="",
94 Double_t gridlength = 0, Bool_t drawGridOnly = kFALSE);
95 virtual void Rotate(Double_t X, Double_t Y, Double_t CFI, Double_t SFI
96 ,Double_t XT, Double_t YT, Double_t &U, Double_t &V);
98 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
99 void SetFunction(const char *funcname="");
100 void SetOption(Option_t *option="");
101 void SetLabelColor(Int_t labelcolor) {fLabelColor = labelcolor;} // *MENU*
102 void SetLabelFont(Int_t labelfont) {fLabelFont = labelfont;} // *MENU*
103 void SetLabelOffset(Float_t labeloffset) {fLabelOffset = labeloffset;} // *MENU*
104 void SetLabelSize(Float_t labelsize) {fLabelSize = labelsize;} // *MENU*
105 void ChangeLabel(Int_t labNum=0, Double_t labAngle = -1.,
106 Double_t labSize = -1., Int_t labAlign = -1,
107 Int_t labColor = -1 , Int_t labFont = -1,
108 TString labText = ""); // *MENU*
109 static void SetMaxDigits(Int_t maxd=5);
110 virtual void SetName(const char *name); // *MENU*
111 virtual void SetNdivisions(Int_t ndiv) {fNdiv = ndiv;} // *MENU*
112 virtual void SetMoreLogLabels(Bool_t more=kTRUE); // *MENU*
113 virtual void SetNoExponent(Bool_t noExponent=kTRUE); // *MENU*
114 virtual void SetDecimals(Bool_t dot=kTRUE); // *MENU*
115 void SetTickSize(Float_t ticksize) {fTickSize = ticksize;} // *MENU*
116 void SetTickLength(Float_t ticklength) {SetTickSize(ticklength);}
117 void SetGridLength(Float_t gridlength) {fGridLength = gridlength;}
118 void SetTimeFormat(const char *tformat);
119 void SetTimeOffset(Double_t toffset, Option_t *option="local");
120 virtual void SetTitle(const char *title=""); // *MENU*
121 void SetTitleOffset(Float_t titleoffset=1) {fTitleOffset = titleoffset;} // *MENU*
122 void SetTitleSize(Float_t titlesize) {fTitleSize = titlesize;} // *MENU*
123 void SetTitleFont(Int_t titlefont) {SetTextFont(titlefont);} // *MENU*
124 void SetTitleColor(Int_t titlecolor) {SetTextColor(titlecolor);} // *MENU*
127 static void SetExponentOffset(Float_t xoff=0., Float_t yoff=0., Option_t *axis="xy");
129 ClassDefOverride(TGaxis,6) //Graphics axis
#define c(i)
Definition: RSha256.hxx:101
bool Bool_t
Definition: RtypesCore.h:63
int Int_t
Definition: RtypesCore.h:45
const Bool_t kFALSE
Definition: RtypesCore.h:101
float Float_t
Definition: RtypesCore.h:57
double Double_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t wmin
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t wmax
char name[80]
Definition: TGX11.cxx:110
float xmin
Definition: THbookFile.cxx:95
float ymin
Definition: THbookFile.cxx:95
float xmax
Definition: THbookFile.cxx:95
float ymax
Definition: THbookFile.cxx:95
Text Attributes class.
Definition: TAttText.h:18
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition: TAttText.h:44
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition: TAttText.h:46
Class to manage histogram axis.
Definition: TAxis.h:30
1-Dim function class
Definition: TF1.h:213
The axis painter class.
Definition: TGaxis.h:23
virtual void SetNoExponent(Bool_t noExponent=kTRUE)
Set the NoExponent flag.
Definition: TGaxis.cxx:2814
void SetTimeFormat(const char *tformat)
Change the format used for time plotting.
Definition: TGaxis.cxx:2858
virtual void PaintAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, Double_t &wmin, Double_t &wmax, Int_t &ndiv, Option_t *chopt="", Double_t gridlength=0, Bool_t drawGridOnly=kFALSE)
Control function to draw an axis.
Definition: TGaxis.cxx:1007
TGaxis default constructor.
Definition: TGaxis.cxx:694
void SetTitleOffset(Float_t titleoffset=1)
Definition: TGaxis.h:121
Float_t fTitleSize
Size of title in NDC.
Definition: TGaxis.h:34
Float_t GetGridLength() const
Definition: TGaxis.h:73
void SetLabelFont(Int_t labelfont)
Definition: TGaxis.h:102
void SetTitleSize(Float_t titlesize)
Definition: TGaxis.h:122
Double_t GetWmin() const
Definition: TGaxis.h:86
Float_t fTitleOffset
Offset of title wrt axis.
Definition: TGaxis.h:33
const char * GetOption() const override
Definition: TGaxis.h:82
TString fTitle
Axis title.
Definition: TGaxis.h:41
Int_t fLabelFont
Font for labels.
Definition: TGaxis.h:37
void SetTitleFont(Int_t titlefont)
Definition: TGaxis.h:123
virtual void SetTitle(const char *title="")
Change the title of the axis.
Definition: TGaxis.cxx:2831
Int_t fLabelColor
Color for labels.
Definition: TGaxis.h:36
TAxis * fAxis
! Pointer to original TAxis axis (if any)
Definition: TGaxis.h:45
TString fTimeFormat
Time format, ex: 09/12/99 12:34:00.
Definition: TGaxis.h:42
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition: TGaxis.cxx:2548
TString fFunctionName
Name of mapping function pointed by fFunction.
Definition: TGaxis.h:43
void SetLabelOffset(Float_t labeloffset)
Definition: TGaxis.h:103
virtual void Rotate(Double_t X, Double_t Y, Double_t CFI, Double_t SFI, Double_t XT, Double_t YT, Double_t &U, Double_t &V)
Internal method to rotate axis coordinates.
Definition: TGaxis.cxx:2538
Float_t GetLabelOffset() const
Definition: TGaxis.h:77
void SetTimeOffset(Double_t toffset, Option_t *option="local")
Change the time offset. If option = "gmt", set display mode to GMT.
Definition: TGaxis.cxx:2882
Float_t fTickSize
Size of primary tick mark in NDC.
Definition: TGaxis.h:30
TF1 * GetFunction() const
Definition: TGaxis.h:74
virtual void ImportAxisAttributes(TAxis *axis)
Internal method to import TAxis attributes to this TGaxis.
Definition: TGaxis.cxx:955
Int_t GetLabelFont() const
Definition: TGaxis.h:76
Float_t fLabelOffset
Offset of label wrt axis.
Definition: TGaxis.h:31
static void SetMaxDigits(Int_t maxd=5)
Static function to set fgMaxDigits for axis.
Definition: TGaxis.cxx:2785
Float_t fLabelSize
Size of labels in NDC.
Definition: TGaxis.h:32
Int_t fNdiv
Number of divisions.
Definition: TGaxis.h:35
void SetGridLength(Float_t gridlength)
Definition: TGaxis.h:117
void ChangeLabelAttributes(Int_t i, Int_t nlabels, TLatex *t, char *c)
Helper method used by TGaxis::ChangeLabel.
Definition: TGaxis.cxx:2729
const char * GetTitle() const override
Returns title of object.
Definition: TGaxis.h:83
TString fChopt
Axis options.
Definition: TGaxis.h:39
TGaxis & operator=(const TGaxis &)
Assignment operator.
Definition: TGaxis.cxx:828
TString fName
Axis name.
Definition: TGaxis.h:40
Float_t GetTitleOffset() const
Definition: TGaxis.h:79
TF1 * fFunction
! Pointer to function computing axis values
Definition: TGaxis.h:44
virtual void SetNdivisions(Int_t ndiv)
Definition: TGaxis.h:111
void SetWmax(Double_t wmax)
Definition: TGaxis.h:126
void ChangeLabel(Int_t labNum=0, Double_t labAngle=-1., Double_t labSize=-1., Int_t labAlign=-1, Int_t labColor=-1, Int_t labFont=-1, TString labText="")
Define new text attributes for the label number "labNum".
Definition: TGaxis.cxx:2680
Float_t GetTitleSize() const
Definition: TGaxis.h:80
static Int_t GetMaxDigits()
Static function returning gStyle->GetAxisMaxDigits().
Definition: TGaxis.cxx:947
virtual void CenterLabels(Bool_t center=kTRUE)
If center = kTRUE axis labels are centered in the center of the bin.
Definition: TGaxis.cxx:896
const char * GetName() const override
Returns name of object.
Definition: TGaxis.h:81
void SetLabelColor(Int_t labelcolor)
Definition: TGaxis.h:101
virtual void AdjustBinSize(Double_t A1, Double_t A2, Int_t nold, Double_t &BinLow, Double_t &BinHigh, Int_t &nbins, Double_t &BinWidth)
Internal method for axis labels optimisation.
Definition: TGaxis.cxx:2491
void SetTickLength(Float_t ticklength)
Definition: TGaxis.h:116
Float_t fGridLength
Length of the grid in NDC.
Definition: TGaxis.h:29
Int_t GetLabelColor() const
Definition: TGaxis.h:75
virtual void SetDecimals(Bool_t dot=kTRUE)
Set the decimals flag.
Definition: TGaxis.cxx:2612
virtual void CenterTitle(Bool_t center=kTRUE)
If center = kTRUE axis title will be centered. The default is right adjusted.
Definition: TGaxis.cxx:906
void SetTitleColor(Int_t titlecolor)
Definition: TGaxis.h:124
virtual ~TGaxis()
TGaxis default destructor.
Definition: TGaxis.cxx:861
TList * fModLabs
List of modified labels.
Definition: TGaxis.h:46
void CleanupModLabs()
Correctly cleanup fModLabs - delete content when owned by TGaxis.
Definition: TGaxis.cxx:881
Double_t fWmax
Highest value on the axis.
Definition: TGaxis.h:28
Float_t GetTickSize() const
Definition: TGaxis.h:88
virtual TGaxis * DrawAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, Double_t wmin, Double_t wmax, Int_t ndiv=510, Option_t *chopt="", Double_t gridlength=0)
Draw this axis with new attributes.
Definition: TGaxis.cxx:916
virtual void SetMoreLogLabels(Bool_t more=kTRUE)
Set the kMoreLogLabels bit flag.
Definition: TGaxis.cxx:2803
void SetWmin(Double_t wmin)
Definition: TGaxis.h:125
void SetTickSize(Float_t ticksize)
Definition: TGaxis.h:115
Int_t GetNdiv() const
Definition: TGaxis.h:85
void Paint(Option_t *chopt="") override
Draw this axis with its current attributes.
Definition: TGaxis.cxx:986
Int_t fNModLabs
Number of modified labels.
Definition: TGaxis.h:38
Double_t fWmin
Lowest value on the axis.
Definition: TGaxis.h:27
void SetLabelSize(Float_t labelsize)
Definition: TGaxis.h:104
void SetFunction(const char *funcname="")
Specify a function to map the axis values.
Definition: TGaxis.cxx:2621
virtual void SetName(const char *name)
Change the name of the axis.
Definition: TGaxis.cxx:2793
static void SetExponentOffset(Float_t xoff=0., Float_t yoff=0., Option_t *axis="xy")
Static method to set X and Y offset of the axis 10^n notation.
Definition: TGaxis.cxx:2924
void LabelsLimits(const char *label, Int_t &first, Int_t &last)
Internal method to find first and last character of a label.
Definition: TGaxis.cxx:2526
Double_t GetWmax() const
Definition: TGaxis.h:87
Bool_t IsOwnedModLabs() const
Returns kTRUE when fModLabs owned by TGaxis and should be cleaned up.
Definition: TGaxis.cxx:869
void ResetLabelAttributes(TLatex *t)
Helper method used by TGaxis::ChangeLabel.
Definition: TGaxis.cxx:2765
Float_t GetLabelSize() const
Definition: TGaxis.h:78
void SetOption(Option_t *option="")
To set axis options.
Definition: TGaxis.cxx:2823
To draw Mathematical Formula.
Definition: TLatex.h:18
Use the TLine constructor to create a simple line.
Definition: TLine.h:22
A doubly linked list.
Definition: TList.h:38
Basic string class.
Definition: TString.h:136
const char * Data() const
Definition: TString.h:369
Definition: first.py:1