Logo ROOT  
Reference Guide
gaxis3.C File Reference

Detailed Description

View in nbviewer Open in SWAN Example illustrating how to modify individual labels of a TGaxis.

The method ChangeLabel allows to do that.

The first parameter of this method is the label number to be modified. If this number is negative labels are numbered from the last one. The other parameters are (in order):

  • the new angle value,
  • the new size (0 erase the label),
  • the new text alignment,
  • the new label color, = the new label text.
void gaxis3() {
TCanvas* c1 = new TCanvas("c1","Examples of Gaxis",10,10,800,400);
c1->Range(-6,-0.1,6,0.1);
TGaxis *axis = new TGaxis(-5.5,0.,5.5,0.,0.0,100,510,"");
axis->SetName("axis");
axis->SetTitle("Axis Title");
axis->SetTitleSize(0.05);
axis->SetTitleFont(42);
// Change the 1st label color to red.
axis->ChangeLabel(1,-1,-1,-1,2);
// Erase the 3rd label
axis->ChangeLabel(3,-1,0.);
// 5th label is drawn with an angle of 30 degrees
axis->ChangeLabel(5,30.,-1,0);
// Change the text of the 6th label.
axis->ChangeLabel(6,-1,-1,-1,3,-1,"6th label");
// Change the text of the 2nd label to the end.
axis->ChangeLabel(-2,-1,-1,-1,3,-1,"2nd to last label");
axis->Draw();
}
@ kBlue
Definition: Rtypes.h:64
The Canvas class.
Definition: TCanvas.h:31
The axis painter class.
Definition: TGaxis.h:24
void SetTitleSize(Float_t titlesize)
Definition: TGaxis.h:126
void SetTitleFont(Int_t titlefont)
Definition: TGaxis.h:127
virtual void SetTitle(const char *title="")
Change the title of the axis.
Definition: TGaxis.cxx:2696
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:2561
void SetTitleColor(Int_t titlecolor)
Definition: TGaxis.h:128
virtual void SetName(const char *name)
Change the name of the axis.
Definition: TGaxis.cxx:2658
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:195
return c1
Definition: legend1.C:41
Author
Olivier Couet

Definition in file gaxis3.C.