Dear Rooters,
I’m trying to draw an axis that occupies only half of the canvas, matching the style I set in the rest of my code. My axis1 does not respond fully to the style I set from gStyle: only the TickLength is as expected. Therefore, I try to explicitly set the text font and label size: axis1->SetTextFont(132) and axis1->SetLabelSize(0.05). Although the output of axis1->GetTextFont() and axis1->GetTickLength() have the correct values, when drawn it doesn’t look as expected: only the LabelSize is correct. This happens both in the plot that the CINT produces and in the pdf as I save it.
My goal is to make a plot on the right half of the canvas and write text on the left half of the canvas. I had chosen to do it this way because I can easily match the vertical position of the text with the y-coordinate of my points. Would you find a solution for my problem or suggest me a better way to do this?
My code:
---------------globally set for my entire macro------------------
gStyle->SetTextFont(132);
gStyle->SetTextSize(0.06);
gStyle->SetTitleFont(132,"x");
gStyle->SetTitleFont(132,"y");
gStyle->SetTitleFont(132,"z");
gStyle->SetLabelFont(132,"x");
gStyle->SetLabelFont(132,"y");
gStyle->SetLabelFont(132,"z");
gStyle->SetLabelSize(0.05,"x");
gStyle->SetTitleSize(0.06,"x");
gStyle->SetLabelSize(0.05,"y");
gStyle->SetTitleSize(0.06,"y");
gStyle->SetLabelSize(0.05,"z");
gStyle->SetTitleSize(0.06,"z");
gStyle->SetTickLength(0.03,"x");//yo
gStyle->SetTickLength(0.03,"y");
gStyle->SetTickLength(0.03,"z");
--------------------------------------------------------------------------
TCanvas *c4=new TCanvas("c4"," ",1200,700);
SetCanvasStyle (c4);
c4->Range(-0.45-0.2,-0.5-0.5,2+0.2,5.5+0.5);
TGaxis *axis1 = new TGaxis();
axis1->SetName("axis1");
cout << "Tick length: " << axis1->GetTickSize() << endl; //This outputs 0.03
//axis1->SetTickLength(0.03);
axis1->SetLabelSize(0.05);
cout << "Text font: " << axis1->GetTextFont() <<endl; //This outputs 62
axis1->SetTextFont(132);
axis1->DrawAxis(0.8,-0.5,2,-0.5,0.8,2,510,"+");
cout << "Text font: " << axis1->GetTextFont() <<endl; //This outputs 132
c4->Update();
Cheers,
Flavia.
ROOT Version: 6.14/04
_Platform: Ubuntu 18.04.2 LTS (bionic),
Linux 4.15.0-54-generic #58-Ubuntu SMP Mon Jun 24 10:55:24 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
_Compiler: ROOT CINT