Setting A DiLog Axis

Hi all!

I would like to scale my data to the DiLog on a TGraph to be able to compare large and small values with potentially positive and negative numbers along the y axis. I would like this with the appropriate scale in y in factors of 10 as when one performs Canvas->SetLogy(). However, I do not know how to replace the main axes.

This is what I have so far:

Double_t y[5] = {-1.E-3, 1.E5, -1.E4, 1.E-6, -1.E-2};
Double_t y_scaled[5];
Double_t x[5] = {1, 2, 3, 4, 5};
TF1 * f_dl = new TF1 ("f_dl", "TMath::DiLog(x)", -1.E5, 1.E5 ); 

for (int var_i = 0; var_i<5; var_i++){
    y_scaled[var_i] = TMath::DiLog(y[var_i]);
    std::cout<<y_scaled[var_i]<<std::endl;
}

TGraph * g = new TGraph (5, x, y_scaled);
TCanvas *c2 = new TCanvas("c2","c2",10,10,700,500);
gPad->DrawFrame(0.,-2.,10.,2);
TGaxis *axis_dl = new TGaxis(0,0,10,0,"f_dl",505,"");
g->SetMarkerStyle(10);
g->Draw("AP");
axis_dl->Draw("same");

I have tried to use the examples provided in [1] but sadly, I have not been able to get these to work.

Can anyone point me in the right direction?

Kind Regards,

Jack

[1] https://root.cern.ch/doc/master/classTGaxis.html


ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


DrawFrame and graph drawing with option “AP” are conflicting. The option “A” redefining the axis. And the coordinates defined by DrawFrame are ignored.

{
Double_t y[5] = {-1.E-3, 1.E5, -1.E4, 1.E-6, -1.E-2};
Double_t y_scaled[5];
Double_t x[5] = {1, 2, 3, 4, 5};
TF1 * f_dl = new TF1 ("f_dl", "TMath::DiLog(x)", -1.E5, 1.E5 );

for (int var_i = 0; var_i<5; var_i++){
    y_scaled[var_i] = TMath::DiLog(y[var_i]);
    std::cout<<y_scaled[var_i]<<std::endl;
}

TGraph * g = new TGraph (5, x, y_scaled);
TCanvas *c2 = new TCanvas("c2","c2",10,10,700,500);
gPad->DrawFrame(0.,-2.,10.,2);
TGaxis *axis_dl = new TGaxis(0,0,10,0,"f_dl",505,"");
g->SetMarkerStyle(10);
g->Draw("P");
axis_dl->Draw();
}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.