ROOT Version: 6.12/04
Platform: fedora 27
_Compiler:_gcc version 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC)
Dear co-rooters.
I am trying to perform a rather simple task, which is to create a plot with double x-axes.
The second axis can be derived by applying a function to the values of the first one which ranges from x1
to x2
.
The function has the format f(x) = A/x^2
To do that I defined the function f(x)
which is used to create the axis by calling the
TGaxis (Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax, const char *funcname, Int_t ndiv=510, Option_t *chopt="", Double_t gridlength=0)
constructor. The problem is that whatever the function I use, the axis is always the same. To illustrate that take a look at the following example
{
// Draw a canvas and a pad
TCanvas *c2 = new TCanvas("c2","c2",10,10,700,500);
gPad->DrawFrame(0.,-2.,10.,2);
// 1st axis f(x) = x, 0.1 < x < 100
TF1 *f1 = new TF1("f1", "pow(x,1)",0.1, 100);
TGaxis *axis1 = new TGaxis(0, 1.5, 10, 1.5,"f1",505,"G-");
axis1->Draw();
axis1->SetTitle("x, (0.1, 100)");
// 2nd axis f(x) = x^2, 0.1 < x < 100
TF1 *f2 = new TF1("f2", "pow(x,2)",0.1, 100);
TGaxis *axis2 = new TGaxis(0, 0.5, 10, 0.5,"f2",505,"G-");
axis2->Draw();
axis2->SetTitle("x^{2}, (0.1, 100)");
// 3rd axis, f(x) = 1/x^2, 0.1 < x <x 100
TF1 *f3 = new TF1("f3", "pow(x,-2)",0.1, 100);
TGaxis *axis3 = new TGaxis(0, -0.5, 10, -0.5,"f3",505,"G-");
axis3->Draw();
axis3->SetTitle("x^{-2}, (0.1, 100)");
// 4th axis, f(x) = 1/x^1, 100 < x < 0.1
TF1 *f4 = new TF1("f4", "pow(x,-2)",100, 0.1);
TGaxis *axis4 = new TGaxis(0, -1.5, 10, -1.5,"f4",505,"G-");
axis4->Draw();
axis4->SetTitle("x^{-2}, (100, 0.1)");
}
The result is a set of 4 axes which are identical!
Any idea on what am I doing wrong?
Thanks in advance!
P.S. : I have also tried the same in root 5.34 and I get the same.