Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
gaxis3.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_graphics
3/// \notebook
4/// Example illustrating how to modify individual labels of a TGaxis. The method
5/// `ChangeLabel` allows to do that.
6///
7/// The first parameter of this method is the label number to be modified. If
8/// this number is negative labels are numbered from the last one. The other
9/// parameters are (in order):
10/// - the new angle value,
11/// - the new size (0 erase the label),
12/// - the new text alignment,
13/// - the new label color,
14/// - the new label text.
15///
16/// \macro_image
17/// \macro_code
18///
19/// \author Olivier Couet
20
21void gaxis3()
22{
23 TCanvas *c1 = new TCanvas("c1", "Examples of TGaxis", 10, 10, 800, 400);
24 c1->Range(-6, -0.1, 6, 0.1);
25
26 TGaxis *axis = new TGaxis(-5.5, 0., 5.5, 0., 0.0, 100, 510, "");
27 axis->SetName("axis");
28 axis->SetTitle("Axis Title");
29 axis->SetTitleSize(0.05);
30 axis->SetTitleColor(kBlue);
31 axis->SetTitleFont(42);
32
33 // Change the 1st label color to red.
34 axis->ChangeLabel(1, -1, -1, -1, kRed);
35
36 // Erase the 3rd label
37 axis->ChangeLabel(3, -1, 0.);
38
39 // 5th label is drawn with an angle of 30 degrees
40 axis->ChangeLabel(5, 30., -1, 0);
41
42 // Change the text of the 6th label.
43 axis->ChangeLabel(6, -1, -1, -1, kGreen, -1, "6th label");
44
45 // Change the text of the 2nd label to the end.
46 axis->ChangeLabel(-2, -1, -1, -1, kGreen, -1, "2nd to last label");
47
48 // Change the text of value 30 by "value of 30"
49 axis->ChangeLabelByValue(30., -1, -1, -1, kBlue, -1, "value of 30");
50
51 axis->Draw();
52}
@ kRed
Definition Rtypes.h:66
@ kGreen
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
The Canvas class.
Definition TCanvas.h:23
The axis painter class.
Definition TGaxis.h:26
void SetTitleSize(Float_t titlesize)
Definition TGaxis.h:131
void SetTitleFont(Int_t titlefont)
Definition TGaxis.h:132
virtual void SetTitle(const char *title="")
Change the title of the axis.
Definition TGaxis.cxx:2942
void ChangeLabelByValue(Double_t labValue, Double_t labAngle=-1., Double_t labSize=-1., Int_t labAlign=-1, Int_t labColor=-1, Int_t labFont=-1, const TString &labText="")
Define new text attributes for the label value "labValue".
Definition TGaxis.cxx:2813
void SetTitleColor(Int_t titlecolor)
Definition TGaxis.h:133
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, const TString &labText="")
Define new text attributes for the label number "labNum".
Definition TGaxis.cxx:2734
virtual void SetName(const char *name)
Change the name of the axis.
Definition TGaxis.cxx:2904
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:292
return c1
Definition legend1.C:41