Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
21 void gaxis3() {
22  TCanvas* c1 = new TCanvas("c1","Examples of Gaxis",10,10,800,400);
23  c1->Range(-6,-0.1,6,0.1);
24 
25  TGaxis *axis = new TGaxis(-5.5,0.,5.5,0.,0.0,100,510,"");
26  axis->SetName("axis");
27  axis->SetTitle("Axis Title");
28  axis->SetTitleSize(0.05);
29  axis->SetTitleColor(kBlue);
30  axis->SetTitleFont(42);
31 
32  // Change the 1st label color to red.
33  axis->ChangeLabel(1,-1,-1,-1,2);
34 
35  // Erase the 3rd label
36  axis->ChangeLabel(3,-1,0.);
37 
38  // 5th label is drawn with an angle of 30 degrees
39  axis->ChangeLabel(5,30.,-1,0);
40 
41  // Change the text of the 6th label.
42  axis->ChangeLabel(6,-1,-1,-1,3,-1,"6th label");
43 
44  // Change the text of the 2nd label to the end.
45  axis->ChangeLabel(-2,-1,-1,-1,3,-1,"2nd to last label");
46 
47  axis->Draw();
48 }