39 Int_t TGaxis::fgMaxDigits = 5;
40 Float_t TGaxis::fXAxisExpXOffset = 0.;
41 Float_t TGaxis::fXAxisExpYOffset = 0.;
42 Float_t TGaxis::fYAxisExpXOffset = 0.;
43 Float_t TGaxis::fYAxisExpYOffset = 0.;
44 const Int_t kHori = BIT(9);
680 TGaxis::TGaxis(): TLine(), TAttText(11,0,1,62,0.040)
684 fLabelOffset = 0.005;
690 fTitleSize = fLabelSize;
708 TGaxis::TGaxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax,
709 Double_t wmin, Double_t wmax, Int_t ndiv, Option_t *chopt,
711 : TLine(xmin,ymin,xmax,ymax), TAttText(11,0,1,62,0.040)
719 fGridLength = gridlength;
720 fLabelOffset = 0.005;
726 fTitleSize = fLabelSize;
739 TGaxis::TGaxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax,
740 const char *funcname, Int_t ndiv, Option_t *chopt,
742 : TLine(xmin,ymin,xmax,ymax), TAttText(11,0,1,62,0.040)
745 fFunction = (TF1*)gROOT->GetFunction(funcname);
747 Error(
"TGaxis",
"calling constructor with an unknown function: %s", funcname);
751 fWmin = fFunction->GetXmin();
752 fWmax = fFunction->GetXmax();
754 fFunctionName= funcname;
758 fGridLength = gridlength;
759 fLabelOffset = 0.005;
765 fTitleSize = fLabelSize;
776 TGaxis::TGaxis(
const TGaxis& ax) :
781 fGridLength(ax.fGridLength),
782 fTickSize(ax.fTickSize),
783 fLabelOffset(ax.fLabelOffset),
784 fLabelSize(ax.fLabelSize),
785 fTitleOffset(ax.fTitleOffset),
786 fTitleSize(ax.fTitleSize),
788 fLabelColor(ax.fLabelColor),
789 fLabelFont(ax.fLabelFont),
790 fNModLabs(ax.fNModLabs),
794 fTimeFormat(ax.fTimeFormat),
795 fFunctionName(ax.fFunctionName),
796 fFunction(ax.fFunction),
798 fModLabs(ax.fModLabs)
805 TGaxis& TGaxis::operator=(
const TGaxis& ax)
809 TLine::operator=(ax);
810 TAttText::operator=(ax);
813 fGridLength=ax.fGridLength;
814 fTickSize=ax.fTickSize;
815 fLabelOffset=ax.fLabelOffset;
816 fLabelSize=ax.fLabelSize;
817 fTitleOffset=ax.fTitleOffset;
818 fTitleSize=ax.fTitleSize;
820 fModLabs=ax.fModLabs;
821 fLabelColor=ax.fLabelColor;
822 fLabelFont=ax.fLabelFont;
826 fTimeFormat=ax.fTimeFormat;
827 fFunctionName=ax.fFunctionName;
828 fFunction=ax.fFunction;
830 fNModLabs=ax.fNModLabs;
847 void TGaxis::CenterLabels(Bool_t center)
850 if (center) SetBit(TAxis::kCenterLabels);
851 else ResetBit(TAxis::kCenterLabels);
857 void TGaxis::CenterTitle(Bool_t center)
860 if (center) SetBit(TAxis::kCenterTitle);
861 else ResetBit(TAxis::kCenterTitle);
867 void TGaxis::DrawAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax,
868 Double_t wmin, Double_t wmax, Int_t ndiv, Option_t *chopt,
872 TGaxis *newaxis =
new TGaxis(xmin,ymin,xmax,ymax,wmin,wmax,ndiv,chopt,gridlength);
873 newaxis->SetLineColor(fLineColor);
874 newaxis->SetLineWidth(fLineWidth);
875 newaxis->SetLineStyle(fLineStyle);
876 newaxis->SetTextAlign(fTextAlign);
877 newaxis->SetTextAngle(fTextAngle);
878 newaxis->SetTextColor(fTextColor);
879 newaxis->SetTextFont(fTextFont);
880 newaxis->SetTextSize(fTextSize);
881 newaxis->SetTitleSize(fTitleSize);
882 newaxis->SetTitleOffset(fTitleOffset);
883 newaxis->SetLabelFont(fLabelFont);
884 newaxis->SetLabelColor(fLabelColor);
885 newaxis->SetLabelSize(fLabelSize);
886 newaxis->SetLabelOffset(fLabelOffset);
887 newaxis->SetTickSize(fTickSize);
888 newaxis->SetBit(kCanDelete);
889 newaxis->SetTitle(GetTitle());
890 newaxis->SetBit(TAxis::kCenterTitle,TestBit(TAxis::kCenterTitle));
891 newaxis->AppendPad();
897 Int_t TGaxis::GetMaxDigits()
906 void TGaxis::ImportAxisAttributes(TAxis *axis)
910 SetLineColor(axis->GetAxisColor());
911 SetTextColor(axis->GetTitleColor());
912 SetTextFont(axis->GetTitleFont());
913 SetLabelColor(axis->GetLabelColor());
914 SetLabelFont(axis->GetLabelFont());
915 SetLabelSize(axis->GetLabelSize());
916 SetLabelOffset(axis->GetLabelOffset());
917 SetTickSize(axis->GetTickLength());
918 SetTitle(axis->GetTitle());
919 SetTitleOffset(axis->GetTitleOffset());
920 SetTitleSize(axis->GetTitleSize());
921 SetBit(TAxis::kCenterTitle, axis->TestBit(TAxis::kCenterTitle));
922 SetBit(TAxis::kCenterLabels, axis->TestBit(TAxis::kCenterLabels));
923 SetBit(TAxis::kRotateTitle, axis->TestBit(TAxis::kRotateTitle));
924 SetBit(TAxis::kNoExponent, axis->TestBit(TAxis::kNoExponent));
925 SetBit(TAxis::kTickPlus, axis->TestBit(TAxis::kTickPlus));
926 SetBit(TAxis::kTickMinus, axis->TestBit(TAxis::kTickMinus));
927 SetBit(TAxis::kMoreLogLabels, axis->TestBit(TAxis::kMoreLogLabels));
928 if (axis->GetDecimals()) SetBit(TAxis::kDecimals);
929 SetTimeFormat(axis->GetTimeFormat());
935 void TGaxis::Paint(Option_t *)
938 Double_t wmin = fWmin;
939 Double_t wmax = fWmax;
943 Double_t x1 = gPad->XtoPad(fX1);
944 Double_t y1 = gPad->YtoPad(fY1);
945 Double_t x2 = gPad->XtoPad(fX2);
946 Double_t y2 = gPad->YtoPad(fY2);
948 PaintAxis(x1,y1,x2,y2,wmin,wmax,ndiv,fChopt.Data(),fGridLength);
956 void TGaxis::PaintAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t ymax,
957 Double_t &wmin, Double_t &wmax, Int_t &ndiv, Option_t *chopt,
958 Double_t gridlength, Bool_t drawGridOnly)
961 const char *where =
"PaintAxis";
963 Double_t alfa, beta, ratio1, ratio2, grid_side;
964 Double_t axis_lengthN = 0;
965 Double_t axis_length0 = 0;
966 Double_t axis_length1 = 0;
967 Double_t axis_length;
971 Double_t phil, phi, sinphi, cosphi, asinphi, acosphi;
972 Double_t binLow = 0., binLow2 = 0., binLow3 = 0.;
973 Double_t binHigh = 0., binHigh2 = 0., binHigh3 = 0.;
974 Double_t binWidth = 0., binWidth2 = 0., binWidth3 = 0.;
975 Double_t xpl1, xpl2, ypl1, ypl2;
977 Double_t xtick0, xtick1, dxtick=0;
978 Double_t ytick, ytick0, ytick1;
979 Double_t wlabel, dwlabel;
980 Double_t xfactor, yfactor;
981 Double_t xlabel, ylabel, dxlabel;
984 Double_t x0, x1, y0, y1, xx0, xx1, yy0, yy1;
985 xx0 = xx1 = yy0 = yy1 = 0;
986 Double_t xxmin, xxmax, yymin, yymax;
987 xxmin = xxmax = yymin = yymax = 0;
988 Double_t xlside, xmside;
989 Double_t ww, af, rne;
991 Double_t xmnlog, x00, x11, h2, h2sav, axmul, y;
992 Float_t chupxvsav, chupyvsav;
994 Int_t nlabels, nticks, nticks0, nticks1;
995 Int_t i, j, k, l, decade, ltick;
999 Int_t iexe, if1, if2, na, nf, ih1, ih2, nbinin, nch, kmod;
1000 Int_t optionLog,optionBlank,optionVert,optionPlus,optionMinus,optionUnlab,optionPara;
1001 Int_t optionDown,optionRight,optionLeft,optionCent,optionEqual,optionDecimals=0,optionDot;
1002 Int_t optionY,optionText,optionGrid,optionSize,optionNoopt,optionInt,optionM,optionUp,optionX;
1004 Int_t first=0,last=0,labelnumber;
1005 Int_t xalign, yalign;
1006 Int_t nn1, nn2, nn3, n1a, n2a, n3a, nb2, nb3;
1007 Int_t nbins=10, n1aold, nn1old;
1009 n1aold = nn1old = 0;
1014 Bool_t flexpo,flexne;
1024 Double_t timed, wTimeIni;
1026 Double_t rangeOffset = 0;
1028 Double_t epsilon = 1e-5;
1029 const Double_t kPI = TMath::Pi();
1031 Double_t rwmi = wmin;
1032 Double_t rwma = wmax;
1033 chtemp = &kchtemp[0];
1034 label = &chlabel[0];
1037 fFunction = (TF1*)gROOT->GetFunction(fFunctionName.Data());
1039 Bool_t noExponent = TestBit(TAxis::kNoExponent);
1042 Bool_t moreLogLabels = TestBit(TAxis::kMoreLogLabels);
1047 Double_t padh = gPad->GetWh()*gPad->GetAbsHNDC();
1048 Double_t rwxmin = gPad->GetX1();
1049 Double_t rwxmax = gPad->GetX2();
1050 Double_t rwymin = gPad->GetY1();
1051 Double_t rwymax = gPad->GetY2();
1053 if(strchr(chopt,
'G')) optionLog = 1;
else optionLog = 0;
1054 if(strchr(chopt,
'B')) optionBlank= 1;
else optionBlank= 0;
1055 if(strchr(chopt,
'V')) optionVert = 1;
else optionVert = 0;
1056 if(strchr(chopt,
'+')) optionPlus = 1;
else optionPlus = 0;
1057 if(strchr(chopt,
'-')) optionMinus= 1;
else optionMinus= 0;
1058 if(strchr(chopt,
'U')) optionUnlab= 1;
else optionUnlab= 0;
1059 if(strchr(chopt,
'P')) optionPara = 1;
else optionPara = 0;
1060 if(strchr(chopt,
'O')) optionDown = 1;
else optionDown = 0;
1061 if(strchr(chopt,
'R')) optionRight= 1;
else optionRight= 0;
1062 if(strchr(chopt,
'L')) optionLeft = 1;
else optionLeft = 0;
1063 if(strchr(chopt,
'C')) optionCent = 1;
else optionCent = 0;
1064 if(strchr(chopt,
'=')) optionEqual= 1;
else optionEqual= 0;
1065 if(strchr(chopt,
'Y')) optionY = 1;
else optionY = 0;
1066 if(strchr(chopt,
'T')) optionText = 1;
else optionText = 0;
1067 if(strchr(chopt,
'W')) optionGrid = 1;
else optionGrid = 0;
1068 if(strchr(chopt,
'S')) optionSize = 1;
else optionSize = 0;
1069 if(strchr(chopt,
'N')) optionNoopt= 1;
else optionNoopt= 0;
1070 if(strchr(chopt,
'I')) optionInt = 1;
else optionInt = 0;
1071 if(strchr(chopt,
'M')) optionM = 1;
else optionM = 0;
1072 if(strchr(chopt,
'0')) optionUp = 1;
else optionUp = 0;
1073 if(strchr(chopt,
'X')) optionX = 1;
else optionX = 0;
1074 if(strchr(chopt,
't')) optionTime = 1;
else optionTime = 0;
1075 if(strchr(chopt,
'.')) optionDot = 1;
else optionDot = 0;
1076 if (TestBit(TAxis::kTickPlus)) optionPlus = 2;
1077 if (TestBit(TAxis::kTickMinus)) optionMinus = 2;
1078 if (TestBit(TAxis::kCenterLabels)) optionM = 1;
1079 if (TestBit(TAxis::kDecimals)) optionDecimals = 1;
1080 if (!gStyle->GetStripDecimals()) optionDecimals = 1;
1082 if (fAxis->GetLabels()) {
1085 ndiv = fAxis->GetLast()-fAxis->GetFirst()+1;
1087 TList *ml = fAxis->GetModifiedLabels();
1090 fNModLabs = fModLabs->GetSize();
1097 Error(where,
"Invalid number of divisions: %d",ndiv);
1104 if (gridlength == 0) gridlength = 0.8;
1105 linegrid =
new TLine();
1106 linegrid->SetLineColor(gStyle->GetGridColor());
1107 if (linegrid->GetLineColor() == 0) linegrid->SetLineColor(GetLineColor());
1108 linegrid->SetLineStyle(gStyle->GetGridStyle());
1109 linegrid->SetLineWidth(gStyle->GetGridWidth());
1115 if (GetLabelOffset() > 1.1 ) optionUnlab = 1;
1119 Int_t idF = fTimeFormat.Index(
"%F");
1121 timeformat = fTimeFormat(0,idF);
1123 timeformat = fTimeFormat;
1127 if (fTimeFormat.Index(
"GMT")>=0) optionTime =2;
1130 Double_t timeoffset =0;
1133 Int_t lnF = fTimeFormat.Length();
1134 TString stringtimeoffset = fTimeFormat(idF+2,lnF);
1135 Int_t year, mm, dd, hh, mi, ss;
1136 if (sscanf(stringtimeoffset.Data(),
"%d-%d-%d %d:%d:%d", &year, &mm, &dd, &hh, &mi, &ss) == 6) {
1139 tp.tm_year = year-1900;
1146 timeoffset = TTimeStamp::MktimeFromUTC(&tp);
1149 Int_t ids = stringtimeoffset.Index(
"s");
1152 Int_t lns = stringtimeoffset.Length();
1153 TString sdp = stringtimeoffset(ids+1,lns);
1154 sscanf(sdp.Data(),
"%g",&dp);
1158 Error(where,
"Time offset has not the right format");
1161 timeoffset = gStyle->GetTimeOffset();
1163 wmin += timeoffset - (int)(timeoffset);
1164 wmax += timeoffset - (int)(timeoffset);
1168 time_t timetp = (time_t)((Long_t)(timeoffset));
1169 Double_t range = wmax - wmin;
1170 Long_t rangeBase = 60;
1171 if (range>60) rangeBase = 60*20;
1172 if (range>3600) rangeBase = 3600*20;
1173 if (range>86400) rangeBase = 86400*20;
1174 if (range>2419200) rangeBase = 31556736;
1175 rangeOffset = (Double_t) ((Long_t)(timeoffset)%rangeBase);
1176 if (range>31536000) {
1177 tp0 = gmtime(&timetp);
1184 rangeBase = (timetp-mktime(tp0));
1185 rangeOffset = (Double_t) (rangeBase);
1187 wmax += rangeOffset;
1188 wmin += rangeOffset;
1193 n2a = (ndiv%10000 - n1a)/100;
1194 n3a = (ndiv%1000000 - n2a -n1a)/10000;
1195 nn3 = TMath::Max(n3a,1);
1196 nn2 = TMath::Max(n2a,1)*nn3;
1197 nn1 = TMath::Max(n1a,1)*nn2+1;
1199 maxDigits = (ndiv/1000000);
1200 if (maxDigits==0) maxDigits = fgMaxDigits;
1208 if (wmin == wmax || ndiv == 0 || n1a <= 1 || optionLog) {
1214 if ( (wmax-wmin) < 1 && optionInt) {
1215 Error(where,
"option I not available");
1218 if (!optionNoopt || optionInt ) {
1224 THLimitsFinder::Optimize(wmin,wmax,n1a,binLow,binHigh,nbins,binWidth,fChopt.Data());
1226 if (binLow != Double_t(
int(binLow)) || binWidth != Double_t(
int(binWidth))) {
1227 AdjustBinSize(wmin,wmax,n1a,binLow,binHigh,nbins,binWidth);
1230 if ((wmin-binLow) > epsilon) { binLow += binWidth; nbins--; }
1231 if ((binHigh-wmax) > epsilon) { binHigh -= binWidth; nbins--; }
1233 rtyw = (ymax-ymin)/(wmax-wmin);
1236 yymin = rtyw*(binLow-wmin) + ymin;
1237 yymax = rtyw*(binHigh-wmin) + ymin;
1240 rtxw = (xmax-xmin)/(wmax-wmin);
1241 xxmin = rtxw*(binLow-wmin) + xmin;
1242 xxmax = rtxw*(binHigh-wmin) + xmin;
1248 alfa = (ymax-ymin)/(xmax-xmin);
1249 beta = (ymin*xmax-ymax*xmin)/(xmax-xmin);
1250 yymin = alfa*xxmin + beta;
1251 yymax = alfa*xxmax + beta;
1266 if (!optionNoopt && n2a > 1 && binWidth > 0) {
1267 THLimitsFinder::Optimize(wmin,wmin+binWidth,n2a,binLow2,binHigh2,nb2,binWidth2,fChopt.Data());
1272 if (!optionNoopt && n3a > 1 && binWidth2 > 0) {
1273 THLimitsFinder::Optimize(binLow2,binLow2+binWidth2,n3a,binLow3,binHigh3,nb3,binWidth3,fChopt.Data());
1278 nn3 = TMath::Max(nb3,1);
1279 nn2 = TMath::Max(nb2,1)*nn3;
1280 nn1 = TMath::Max(n1a,1)*nn2+1;
1286 ratio1 = 1/(rwxmax-rwxmin);
1287 ratio2 = 1/(rwymax-rwymin);
1288 x0 = ratio1*(xmin-rwxmin);
1289 x1 = ratio1*(xmax-rwxmin);
1290 y0 = ratio2*(ymin-rwymin);
1291 y1 = ratio2*(ymax-rwymin);
1292 if (!optionNoopt || optionInt ) {
1293 xx0 = ratio1*(xxmin-rwxmin);
1294 xx1 = ratio1*(xxmax-rwxmin);
1295 yy0 = ratio2*(yymin-rwymin);
1296 yy1 = ratio2*(yymax-rwymin);
1299 if ((x0 == x1) && (y0 == y1)) {
1300 Error(where,
"length of axis is 0");
1305 Double_t toffset = GetTitleOffset();
1306 Bool_t autotoff = kFALSE;
1307 if (toffset==0 && x1 == x0) autotoff = kTRUE;
1315 TLatex *textaxis =
new TLatex();
1317 Int_t TitleColor = GetTextColor();
1318 Int_t TitleFont = GetTextFont();
1320 if (!gPad->IsBatch()) {
1321 gVirtualX->GetCharacterUp(chupxvsav, chupyvsav);
1322 gVirtualX->SetClipOFF(gPad->GetCanvasID());
1326 axis_length = TMath::Sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0));
1327 if (axis_length == 0) {
1328 Error(where,
"length of axis is 0");
1331 if (!optionNoopt || optionInt) {
1332 axis_lengthN = TMath::Sqrt((xx1-xx0)*(xx1-xx0)+(yy1-yy0)*(yy1-yy0));
1333 axis_length0 = TMath::Sqrt((xx0-x0)*(xx0-x0)+(yy0-y0)*(yy0-y0));
1334 axis_length1 = TMath::Sqrt((x1-xx1)*(x1-xx1)+(y1-yy1)*(y1-yy1));
1335 if (axis_lengthN < epsilon) {
1344 wmin += timeoffset - (int)(timeoffset) + rangeOffset;
1345 wmax += timeoffset - (int)(timeoffset) + rangeOffset;
1351 if (y1>=y0) phi = 0.5*kPI;
1355 phi = TMath::ATan2((y1-y0),(x1-x0));
1356 Int_t px0 = gPad->UtoPixel(x0);
1357 Int_t py0 = gPad->VtoPixel(y0);
1358 Int_t px1 = gPad->UtoPixel(x1);
1359 Int_t py1 = gPad->VtoPixel(y1);
1360 if (x0 < x1) phil = TMath::ATan2(Double_t(py0-py1), Double_t(px1-px0));
1361 else phil = TMath::ATan2(Double_t(py1-py0), Double_t(px0-px1));
1363 cosphi = TMath::Cos(phi);
1364 sinphi = TMath::Sin(phi);
1365 acosphi = TMath::Abs(cosphi);
1366 asinphi = TMath::Abs(sinphi);
1367 if (acosphi <= epsilon) { acosphi = 0; cosphi = 0; }
1368 if (asinphi <= epsilon) { asinphi = 0; sinphi = 0; }
1376 if (x0 == x1 && y1 > y0) mside = -1;
1377 if (optionPlus) mside = 1;
1378 if (optionMinus) mside = -1;
1379 if (optionPlus && optionMinus) mside = 0;
1382 if (optionEqual) lside = mside;
1383 if (optionPlus && optionMinus) {
1385 if (optionEqual) lside=1;
1390 if(xmside >= 0) tick_side = 1;
1391 else tick_side = -1;
1392 if (optionSize) atick[0] = tick_side*axis_length*fTickSize;
1393 else atick[0] = tick_side*axis_length*0.03;
1395 atick[1] = 0.5*atick[0];
1396 atick[2] = 0.5*atick[1];
1399 if ((x0 == x1) && (y1 > y0)) grid_side =-1;
1404 rwmi = fFunction->Eval(wmin);
1405 rwma = fFunction->Eval(wmax);
1419 PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
1424 if (ndiv == 0)
goto L210;
1426 Error(where,
"wmin (%f) == wmax (%f)", wmin, wmax);
1435 charheight = GetLabelSize();
1436 if (optionText && GetLabelFont()%10 != 3) charheight *= 0.66666;
1437 textaxis->SetTextFont(GetLabelFont());
1438 if ((GetLabelFont()%10 < 2) && optionLog)
1439 textaxis->SetTextFont((Int_t)(GetLabelFont()/10)*10+2);
1440 textaxis->SetTextColor(GetLabelColor());
1441 textaxis->SetTextSize (charheight);
1442 textaxis->SetTextAngle(GetTextAngle());
1443 if (GetLabelFont()%10 > 2) {
1446 if (!optionUp && !optionDown && !optionY && !optionUnlab) {
1447 if (!drawGridOnly && optionText && ((ymin == ymax) || (xmin == xmax))) {
1448 textaxis->SetTextAlign(32);
1450 Int_t nl = fAxis->GetLast()-fAxis->GetFirst()+1;
1452 for (i=fAxis->GetFirst(); i<=fAxis->GetLast(); i++) {
1453 textaxis->SetText(0,0,fAxis->GetBinLabel(i));
1454 if (textaxis->GetXsize() < (xmax-xmin)/nl)
continue;
1458 for (i=fAxis->GetFirst(); i<=fAxis->GetLast(); i++) {
1459 if ((!strcmp(fAxis->GetName(),
"xaxis") && !gPad->TestBit(kHori))
1460 ||(!strcmp(fAxis->GetName(),
"yaxis") && gPad->TestBit(kHori))) {
1461 if (nl > 50) angle = 90;
1462 if (fAxis->TestBit(TAxis::kLabelsHori)) angle = 0;
1463 if (fAxis->TestBit(TAxis::kLabelsVert)) angle = 90;
1464 if (fAxis->TestBit(TAxis::kLabelsUp)) angle = 20;
1465 if (fAxis->TestBit(TAxis::kLabelsDown)) angle =-20;
1466 if (angle == 0) textaxis->SetTextAlign(23);
1467 if (angle == -20) textaxis->SetTextAlign(12);
1468 textaxis->SetTextAngle(angle);
1470 if (ymin == gPad->GetUymax()) {
1471 if (angle == 0) textaxis->SetTextAlign(21);
1474 strncpy(chtemp, fAxis->GetBinLabel(i), 255);
1475 if (fNModLabs) ChangeLabelAttributes(i, fAxis->GetLabels()->GetSize()-1, textaxis, chtemp);
1476 textaxis->PaintLatex(fAxis->GetBinCenter(i),
1477 ymin + s*fAxis->GetLabelOffset()*(gPad->GetUymax()-gPad->GetUymin()),
1478 textaxis->GetTextAngle(),
1479 textaxis->GetTextSize(),
1481 if (fNModLabs) ResetLabelAttributes(textaxis);
1482 }
else if ((!strcmp(fAxis->GetName(),
"yaxis") && !gPad->TestBit(kHori))
1483 || (!strcmp(fAxis->GetName(),
"xaxis") && gPad->TestBit(kHori))) {
1485 if (xmin == gPad->GetUxmax()) {
1486 textaxis->SetTextAlign(12);
1491 textaxis->SetText(0.,0., fAxis->GetBinLabel(i));
1492 textaxis->GetBoundingBox(w,h);
1493 toffset = TMath::Max(toffset,(
double)w/((
double)gPad->GetWw()*gPad->GetWNDC()));
1495 textaxis->PaintLatex(xmin + s*fAxis->GetLabelOffset()*(gPad->GetUxmax()-gPad->GetUxmin()),
1496 fAxis->GetBinCenter(i),
1498 textaxis->GetTextSize(),
1499 fAxis->GetBinLabel(i));
1501 textaxis->PaintLatex(xmin - 3*fAxis->GetLabelOffset()*(gPad->GetUxmax()-gPad->GetUxmin()),
1502 ymin +(i-0.5)*(ymax-ymin)/nl,
1504 textaxis->GetTextSize(),
1505 fAxis->GetBinLabel(i));
1512 if (!gPad->IsBatch()) {
1513 if (cosphi > 0) gVirtualX->SetCharacterUp(-sinphi,cosphi);
1514 else gVirtualX->SetCharacterUp(sinphi,-cosphi);
1515 if (x0 == x1) gVirtualX->SetCharacterUp(0,1);
1516 if (optionVert) gVirtualX->SetCharacterUp(0,1);
1517 if (optionPara) gVirtualX->SetCharacterUp(-sinphi,cosphi);
1518 if (optionDown) gVirtualX->SetCharacterUp(cosphi,sinphi);
1524 if (x0 == x1) xalign = 3;
1525 if (y0 != y1) yalign = 2;
1526 if (optionCent) xalign = 2;
1527 if (optionRight) xalign = 3;
1528 if (optionLeft) xalign = 1;
1529 if (TMath::Abs(cosphi) > 0.9) {
1532 if (cosphi*sinphi > 0) xalign = 1;
1533 if (cosphi*sinphi < 0) xalign = 3;
1535 textaxis->SetTextAlign(10*xalign+yalign);
1539 if (optionPlus && !optionMinus) {
1540 if (optionEqual) ylabel = fLabelOffset/2 + atick[0];
1541 else ylabel = -fLabelOffset;
1543 ylabel = fLabelOffset;
1544 if (lside < 0) ylabel += atick[0];
1546 }
else if (y0 == y1) {
1547 if (optionMinus && !optionPlus) {
1548 if ((GetLabelFont() % 10) == 3 ) {
1549 ylabel = fLabelOffset+0.5*
1550 ((gPad->AbsPixeltoY(0)-gPad->AbsPixeltoY((Int_t)fLabelSize))/
1551 (gPad->GetY2() - gPad->GetY1()));
1553 ylabel = fLabelOffset+0.5*fLabelSize;
1555 ylabel += TMath::Abs(atick[0]);
1557 ylabel = -fLabelOffset;
1558 if (mside <= 0) ylabel -= TMath::Abs(atick[0]);
1560 if (optionLog) ylabel -= 0.5*charheight;
1562 if (mside+lside >= 0) ylabel = fLabelOffset;
1563 else ylabel = -fLabelOffset;
1565 if (optionText) ylabel /= 2;
1571 dxtick=(binHigh-binLow)/Double_t(nticks-1);
1573 if (optionNoopt && !optionInt) dxtick=axis_length/Double_t(nticks-1);
1574 else dxtick=axis_lengthN/Double_t(nticks-1);
1576 for (k=0;k<nticks; k++) {
1578 if (k%nn3 == 0) ltick = 1;
1579 if (k%nn2 == 0) ltick = 0;
1581 Double_t xf = binLow+Double_t(k)*dxtick;
1582 Double_t zz = fFunction->Eval(xf)-rwmi;
1583 xtick = zz* axis_length / TMath::Abs(rwma-rwmi);
1585 xtick = Double_t(k)*dxtick;
1588 if (!mside) ytick -= atick[ltick];
1589 if ( optionNoopt && !optionInt) {
1590 Rotate(xtick,ytick,cosphi,sinphi,x0,y0,xpl2,ypl2);
1591 Rotate(xtick,atick[ltick],cosphi,sinphi,x0,y0,xpl1,ypl1);
1594 Rotate(xtick,ytick,cosphi,sinphi,xx0,yy0,xpl2,ypl2);
1595 Rotate(xtick,atick[ltick],cosphi,sinphi,xx0,yy0,xpl1,ypl1);
1598 if ((x0 != x1) && (y0 != y1)) {
1601 if (cosphi > 0) ypl1 = ypl2 + atick[ltick];
1602 else ypl1 = ypl2 - atick[ltick];
1605 xpl1 = 0.5*(xpl1 + xpl2);
1607 ypl1 = 0.5*(ypl1 + ypl2) + atick[ltick];
1608 ypl2 = 0.5*(ypl1 + ypl2) - atick[ltick];
1612 if (!drawGridOnly) PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
1616 if (optionNoopt && !optionInt) {
1617 Rotate(xtick,0,cosphi,sinphi,x0,y0 ,xpl2,ypl2);
1618 Rotate(xtick,grid_side*gridlength ,cosphi,sinphi,x0,y0 ,xpl1,ypl1);
1621 Rotate(xtick,0,cosphi ,sinphi,xx0,yy0 ,xpl2,ypl2);
1622 Rotate(xtick,grid_side*gridlength ,cosphi,sinphi,xx0,yy0 ,xpl1,ypl1);
1624 linegrid->PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
1631 if (fFunction) axis_length0 = binLow-wmin;
1632 if ((!optionNoopt || optionInt) && axis_length0) {
1633 nticks0 = Int_t(axis_length0/dxtick);
1634 if (nticks0 > 1000) nticks0 = 1000;
1635 for (k=0; k<=nticks0; k++) {
1637 if (k%nn3 == 0) ltick = 1;
1638 if (k%nn2 == 0) ltick = 0;
1640 if (!mside) ytick0 -= atick[ltick];
1642 xtick0 = (fFunction->Eval(binLow - Double_t(k)*dxtick)-rwmi)
1643 * axis_length / TMath::Abs(rwma-rwmi);
1645 Rotate(xtick0,ytick0,cosphi,sinphi,xx0,yy0 ,xpl2,ypl2);
1646 Rotate(xtick0,atick[ltick],cosphi,sinphi,xx0,yy0 ,xpl1,ypl1);
1648 if ((x0 != x1) && (y0 != y1)) {
1651 if (cosphi > 0) ypl1 = ypl2 + atick[ltick];
1652 else ypl1 = ypl2 - atick[ltick];
1655 xpl1 = 0.5*(xpl1 + xpl2);
1657 ypl1 = 0.5*(ypl1 + ypl2) + atick[ltick];
1658 ypl2 = 0.5*(ypl1 + ypl2) - atick[ltick];
1662 if (!drawGridOnly) PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
1666 Rotate(xtick0,0,cosphi,sinphi,xx0,yy0,xpl2,ypl2);
1667 Rotate(xtick0,grid_side*gridlength ,cosphi,sinphi,xx0,yy0 ,xpl1,ypl1);
1668 linegrid->PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
1675 if (fFunction) axis_length1 = wmax-binHigh;
1676 if ((!optionNoopt || optionInt) && axis_length1) {
1677 nticks1 = int(axis_length1/dxtick);
1678 if (nticks1 > 1000) nticks1 = 1000;
1679 for (k=0; k<=nticks1; k++) {
1681 if (k%nn3 == 0) ltick = 1;
1682 if (k%nn2 == 0) ltick = 0;
1684 if (!mside) ytick1 -= atick[ltick];
1686 xtick1 = (fFunction->Eval(binHigh + Double_t(k)*dxtick)-rwmi)
1687 * axis_length / TMath::Abs(rwma-rwmi);
1689 Rotate(xtick1,ytick1,cosphi,sinphi,xx0,yy0 ,xpl2,ypl2);
1690 Rotate(xtick1,atick[ltick],cosphi,sinphi,xx0,yy0 ,xpl1,ypl1);
1692 if ((x0 != x1) && (y0 != y1)) {
1695 if (cosphi > 0) ypl1 = ypl2 + atick[ltick];
1696 else ypl1 = ypl2 - atick[ltick];
1699 xpl1 = 0.5*(xpl1 + xpl2);
1701 ypl1 = 0.5*(ypl1 + ypl2) + atick[ltick];
1702 ypl2 = 0.5*(ypl1 + ypl2) - atick[ltick];
1706 if (!drawGridOnly) PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
1709 Rotate(xtick1,0,cosphi,sinphi,xx0,yy0 ,xpl2,ypl2);
1710 Rotate(xtick1,grid_side*gridlength,cosphi,sinphi,xx0,yy0,xpl1,ypl1);
1711 linegrid->PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
1721 if (!drawGridOnly && !optionUnlab) {
1725 if ((wmin == wmax) || (ndiv == 0)) {
1726 Error(where,
"wmin (%f) == wmax (%f), or ndiv == 0", wmin, wmax);
1730 dwlabel = (wmax-wmin)/Double_t(n1a);
1731 if (optionNoopt && !optionInt) dxlabel = axis_length/Double_t(n1a);
1732 else dxlabel = axis_lengthN/Double_t(n1a);
1734 if (!optionText && !optionTime) {
1743 ww = TMath::Max(TMath::Abs(wmin),TMath::Abs(wmax));
1748 Double_t xmicros = 0.00099;
1749 if (maxDigits) xmicros = TMath::Power(10,-maxDigits);
1750 if (!noExponent && (TMath::Abs(wmax-wmin)/Double_t(n1a)) < xmicros) {
1751 af = TMath::Log10(ww) + epsilon;
1755 iexe = TMath::Abs(nexe);
1756 if (iexe%3 == 1) iexe += 2;
1757 else if(iexe%3 == 2) iexe += 1;
1758 if (nexe < 0) nexe = -iexe;
1760 wlabel = wlabel*TMath::Power(10,iexe);
1761 dwlabel = dwlabel*TMath::Power(10,iexe);
1767 if (ww >= 1) af = TMath::Log10(ww);
1768 else af = TMath::Log10(ww*0.0001);
1771 if (!noExponent && nf > maxDigits) flexpo = kTRUE;
1772 if (!noExponent && nf < -maxDigits) flexne = kTRUE;
1783 if (nexe%3 == 0 && ww <= TMath::Power(10,maxDigits-1))
break;
1789 rne = 1/TMath::Power(10,maxDigits-2);
1795 if (nexe%3 == 0 && ww >= rne)
break;
1800 for (i=maxDigits-1; i>0; i--) {
1801 if (TMath::Abs(ww) < TMath::Power(10,i)) na = maxDigits-i;
1805 Double_t wdyn = TMath::Abs((wmax-wmin)/ndyn);
1806 if (wdyn <= 0.999 && na < maxDigits-2) {
1816 if1 = TMath::Max(nf+na,maxDigits)+1;
1818 if (TMath::Min(wmin,wmax) < 0)if1 = if1+1;
1819 if1 = TMath::Min(if1,32);
1822 while (dwlabel < TMath::Power(10,-if2)) {
1826 if (if1 > 14) if1 = 14;
1827 if (if2 > 14) if2 = 14;
1828 if (if1 < 0) if1 = 0;
1831 len = snprintf(chcoded,
sizeof(chcoded),
"%%%d.%df",if1,if2);
1833 len = snprintf(chcoded,
sizeof(chcoded),
"%%%d.%df",if1+1,1);
1836 if ((len < 0) || (len >= (
int)
sizeof(chcoded)))
1837 strcpy(chcoded,
"%7.3f");
1842 snprintf(chtemp,256,
"%g",dwlabel);
1843 Int_t ndecimals = 0;
1844 if (optionDecimals) {
1845 char *dot = strchr(chtemp,
'.');
1847 ndecimals = chtemp + strlen(chtemp) -dot;
1850 exp = strstr(chtemp,
"e-");
1852 sscanf(&exp[2],
"%d",&ndecimals);
1857 if (optionM) nlabels = n1a-1;
1860 for ( k=0; k<=nlabels; k++) {
1862 Double_t xf = binLow+Double_t(k*nn2)*dxtick;
1863 Double_t zz = fFunction->Eval(xf)-rwmi;
1865 xlabel = zz* axis_length / TMath::Abs(rwma-rwmi);
1869 if (optionM) xlabel += 0.5*dxlabel;
1871 if (!optionText && !optionTime) {
1872 snprintf(label,256,chcoded,wlabel);
1876 LabelsLimits(label,first,last);
1878 if (label[first] ==
'.') {
1879 strncpy(chtemp,
"0",256);
1880 strlcat(chtemp, &label[first],256);
1881 strncpy(label, chtemp,256);
1882 first = 1; last = strlen(label);
1884 if (label[first] ==
'-' && label[first+1] ==
'.') {
1885 strncpy(chtemp,
"-0",256);
1886 strlcat(chtemp, &label[first+1],256);
1887 strncpy(label, chtemp, 256);
1888 first = 1; last = strlen(label);
1893 char *adot = strchr(label,
'.');
1894 if (adot) adot[ndecimals] = 0;
1896 while (label[last] ==
'0') { label[last] = 0; last--;}
1900 if (label[last] ==
'.') {
1901 if (!optionDot) { label[last] = 0; last--;}
1905 if (last-first == 1 && label[first] ==
'-'
1906 && label[last] ==
'0') {
1907 strncpy(label,
"0", 256);
1915 timed = wlabel + (int)(timeoffset) - rangeOffset;
1916 timelabel = (time_t)((Long_t)(timed));
1917 if (optionTime == 1) {
1918 utctis = localtime(&timelabel);
1920 utctis = gmtime(&timelabel);
1922 TString timeformattmp;
1923 if (timeformat.Length() < 220) timeformattmp = timeformat;
1924 else timeformattmp =
"#splitline{Format}{too long}";
1930 snprintf(label, 256,
"%%S%7.5f", modf(timed,&tmpdb));
1931 tmplast = strlen(label)-1;
1934 while (label[tmplast] ==
'0') {
1935 label[tmplast] = 0; tmplast--;
1938 timeformattmp.ReplaceAll(
"%S",label);
1940 timeformattmp.ReplaceAll(
"%S0.",
"%Ss");
1944 if (utctis !=
nullptr) {
1945 strftime(label, 256, timeformattmp.Data(), utctis);
1947 strncpy(label,
"invalid", 256);
1949 strncpy(chtemp, &label[0], 256);
1950 first = 0; last=strlen(label)-1;
1951 wlabel = wTimeIni + (k+1)*dwlabel;
1956 if (optionNoopt && !optionInt)
1957 Rotate (xlabel,ylabel,cosphi,sinphi,x0,y0,xx,yy);
1958 else Rotate (xlabel,ylabel,cosphi,sinphi,xx0,yy0,xx,yy);
1959 if (y0 == y1 && !optionDown && !optionUp) {
1960 yy -= 0.80*charheight;
1963 if (x0 != x1 && y0 != y1) {
1964 if (optionNoopt && !optionInt)
1965 Rotate (xlabel,0,cosphi,sinphi,x0,y0,xx,yy);
1966 else Rotate (xlabel,0,cosphi,sinphi,xx0,yy0,xx,yy);
1967 if (cosphi > 0 ) yy += ylabel;
1968 if (cosphi < 0 ) yy -= ylabel;
1971 if (!optionY || (x0 == x1)) {
1973 if (first > last) strncpy(chtemp,
" ", 256);
1974 else strncpy(chtemp, &label[first], 255);
1975 if (fNModLabs) ChangeLabelAttributes(k+1, nlabels, textaxis, chtemp);
1977 if (!optionTime) typolabel.ReplaceAll(
"-",
"#minus");
1980 textaxis->SetText(0.,0., typolabel.Data());
1981 textaxis->GetBoundingBox(w,h);
1982 toffset = TMath::Max(toffset,(
double)w/((
double)gPad->GetWw()*gPad->GetWNDC()));
1984 textaxis->PaintLatex(gPad->GetX1() + xx*(gPad->GetX2() - gPad->GetX1()),
1985 gPad->GetY1() + yy*(gPad->GetY2() - gPad->GetY1()),
1986 textaxis->GetTextAngle(),
1987 textaxis->GetTextSize(),
1989 if (fNModLabs) ResetLabelAttributes(textaxis);
1991 if (optionText == 1) textaxis->PaintLatex(gPad->GetX1() + xx*(gPad->GetX2() - gPad->GetX1()),
1992 gPad->GetY1() + yy*(gPad->GetY2() - gPad->GetY1()),
1994 textaxis->GetTextSize(),
1995 fAxis->GetBinLabel(k+fAxis->GetFirst()));
2000 if (!optionText) lnlen = last-first+1;
2002 if (k+1 > nhilab) lnlen = 0;
2004 for ( l=1; l<=lnlen; l++) {
2005 if (!optionText) *chtemp = label[first+l-2];
2007 if (lnlen == 0) strncpy(chtemp,
" ", 256);
2008 else strncpy(chtemp,
"1", 256);
2011 typolabel.ReplaceAll(
"-",
"#minus");
2012 textaxis->PaintLatex(gPad->GetX1() + xx*(gPad->GetX2() - gPad->GetX1()),
2013 gPad->GetY1() + yy*(gPad->GetY2() - gPad->GetY1()),
2015 textaxis->GetTextSize(),
2017 yy -= charheight*1.3;
2024 if (flexe && !optionText && nexe) {
2025 snprintf(label,256,
"#times10^{%d}", nexe);
2026 if (x0 != x1) { xfactor = axis_length+0.1*charheight; yfactor = 0; }
2027 else { xfactor = y1-y0+0.1*charheight; yfactor = 0; }
2028 Rotate (xfactor,yfactor,cosphi,sinphi,x0,y0,xx,yy);
2029 textaxis->SetTextAlign(11);
2030 if (GetLabelFont()%10 < 2)
2031 textaxis->SetTextFont((Int_t)(GetLabelFont()/10)*10+2);
2032 if (fAxis && !strcmp(fAxis->GetName(),
"xaxis")) {
2033 xx = xx + fXAxisExpXOffset;
2034 yy = yy + fXAxisExpYOffset;
2036 if (fAxis && !strcmp(fAxis->GetName(),
"yaxis")) {
2037 xx = xx + fYAxisExpXOffset;
2038 yy = yy + fYAxisExpYOffset;
2041 typolabel.ReplaceAll(
"-",
"#minus");
2042 textaxis->PaintLatex(gPad->GetX1() + xx*(gPad->GetX2() - gPad->GetX1()),
2043 gPad->GetY1() + yy*(gPad->GetY2() - gPad->GetY1()),
2045 textaxis->GetTextSize(),
2054 if (optionLog && ndiv) {
2055 UInt_t xi1=0,xi2=0,wi=0,yi1=0,yi2=0,hi=0,xl=0,xh=0;
2056 Bool_t firstintlab = kTRUE, overlap = kFALSE;
2057 if ((wmin == wmax) || (ndiv == 0)) {
2058 Error(where,
"wmin (%f) == wmax (%f), or ndiv == 0", wmin, wmax);
2062 Error(where,
"negative logarithmic axis");
2066 Error(where,
"negative logarithmic axis");
2069 xmnlog = TMath::Log10(wmin);
2070 if (xmnlog > 0) xmnlog += 1.E-6;
2071 else xmnlog -= 1.E-6;
2074 h2 = TMath::Log10(wmax);
2076 if (h2 > 0) h2 += 1.E-6;
2081 axmul = (x11-x00)/(h2sav-xmnlog);
2086 if ( xmnlog > 0 && (xmnlog-Double_t(ih1) > 0) ) labelnumber++;
2087 Int_t changelablogid = 0;
2088 Int_t changelablognum = 0;
2089 for (j=1; j<=nbinin; j++) {
2092 firstintlab = kTRUE, overlap = kFALSE;
2094 if (x0 == x1 && j == 1) ylabel += charheight*0.33;
2095 if (y0 == y1 && j == 1) ylabel -= charheight*0.65;
2096 xone = x00+axmul*(Double_t(decade)-xmnlog);
2098 if (j < 0) printf(
"j=%d\n",j);
2099 if (x00 > xone)
goto L160;
2100 if ((xone-x11)>epsilon)
break;
2103 if (!mside) y -= atick[0];
2104 Rotate(xone,y,cosphi,sinphi,x0,y0,xpl2,ypl2);
2105 Rotate(xtwo,atick[0],cosphi,sinphi,x0,y0,xpl1,ypl1);
2107 if ((x0 != x1) && (y0 != y1)) {
2110 if (cosphi > 0) ypl1 = ypl2 + atick[0];
2111 else ypl1 = ypl2 - atick[0];
2114 xpl1 = 0.5*(xpl1 + xpl2);
2116 ypl1 = 0.5*(ypl1 + ypl2) + atick[0];
2117 ypl2 = 0.5*(ypl1 + ypl2) - atick[0];
2121 if (!drawGridOnly) PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
2124 Rotate(xone,0,cosphi,sinphi,x0,y0,xpl2,ypl2);
2125 Rotate(xone,grid_side*gridlength,cosphi,sinphi,x0,y0,xpl1,ypl1);
2126 linegrid->PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
2129 if (!drawGridOnly && !optionUnlab) {
2133 rlab = TMath::Power(10,labelnumber);
2134 snprintf(label,256,
"%f", rlab);
2135 LabelsLimits(label,first,last);
2136 while (last > first) {
2137 if (label[last] !=
'0')
break;
2141 if (label[last] ==
'.') {label[last] = 0; last--;}
2143 snprintf(label,256,
"%d", labelnumber);
2144 LabelsLimits(label,first,last);
2146 Rotate (xone,ylabel,cosphi,sinphi,x0,y0,xx,yy);
2147 if ((x0 == x1) && !optionPara) {
2150 if (labelnumber == 0) nch=1;
2152 xx += nch*charheight;
2154 xx += 0.25*charheight;
2157 xx += 0.25*charheight;
2159 if ((y0 == y1) && !optionDown && !optionUp) {
2160 if (noExponent) yy += 0.33*charheight;
2162 if (n1a == 0)
goto L210;
2164 if (kmod == 0) kmod=1000000;
2165 if ((nbinin <= n1a) || (j == 1) || (j == nbinin) || ((nbinin > n1a) && (j%kmod == 0))) {
2166 if (labelnumber == 0) {
2167 snprintf(chtemp,256,
"1");
2168 }
else if (labelnumber == 1) {
2169 snprintf(chtemp,256,
"10");
2172 chtemp = &label[first];
2174 snprintf(chtemp,256,
"10^{%d}", labelnumber);
2178 if (changelablogid == 0) changelablognum = nbinin-j;
2180 ChangeLabelAttributes(changelablogid, changelablognum, textaxis, chtemp);
2183 typolabel.ReplaceAll(
"-",
"#minus");
2186 textaxis->SetText(0.,0., typolabel.Data());
2187 textaxis->GetBoundingBox(w,h);
2188 toffset = TMath::Max(toffset,(
double)w/((
double)gPad->GetWw()*gPad->GetWNDC()));
2190 textaxis->PaintLatex(gPad->GetX1() + xx*(gPad->GetX2() - gPad->GetX1()),
2191 gPad->GetY1() + yy*(gPad->GetY2() - gPad->GetY1()),
2192 0, textaxis->GetTextSize(), typolabel.Data());
2193 if (fNModLabs) ResetLabelAttributes(textaxis);
2198 for (k=2;k<10;k++) {
2201 xone = x00+axmul*(TMath::Log10(Double_t(k))+Double_t(decade)-xmnlog);
2202 if (x00 > xone)
continue;
2203 if (xone > x11)
goto L200;
2205 if (!mside) y -= atick[1];
2207 Rotate(xone,y,cosphi,sinphi,x0,y0,xpl2,ypl2);
2208 Rotate(xtwo,atick[1],cosphi,sinphi,x0,y0,xpl1,ypl1);
2210 if ((x0 != x1) && (y0 != y1)) {
2213 if (cosphi > 0) ypl1 = ypl2 + atick[1];
2214 else ypl1 = ypl2 - atick[1];
2217 xpl1 = 0.5*(xpl1+xpl2);
2219 ypl1 = 0.5*(ypl1+ypl2) + atick[1];
2220 ypl2 = 0.5*(ypl1+ypl2) - atick[1];
2225 if ((nbinin <= idn) || ((nbinin > idn) && (k == 5))) {
2226 if (!drawGridOnly) PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
2230 if (moreLogLabels && !optionUnlab && !drawGridOnly && !overlap) {
2232 rlab = Double_t(k)*TMath::Power(10,labelnumber-1);
2233 snprintf(chtemp,256,
"%g", rlab);
2235 if (labelnumber-1 == 0) {
2236 snprintf(chtemp,256,
"%d", k);
2237 }
else if (labelnumber-1 == 1) {
2238 snprintf(chtemp,256,
"%d", 10*k);
2240 snprintf(chtemp,256,
"%d#times10^{%d}", k, labelnumber-1);
2243 Rotate (xone,ylabel,cosphi,sinphi,x0,y0,xx,yy);
2244 if ((x0 == x1) && !optionPara) {
2247 if (labelnumber == 0) nch=1;
2249 xx += nch*charheight;
2251 if (labelnumber >= 0) xx += 0.25*charheight;
2252 else xx += 0.50*charheight;
2255 xx += 0.25*charheight;
2257 if ((y0 == y1) && !optionDown && !optionUp) {
2258 if (noExponent) yy += 0.33*charheight;
2261 if ((x0 != x1) && (y0 != y1)) {
2262 Rotate(xone,ylabel,cosphi,sinphi,x0,y0,xx,yy);
2263 if (cosphi > 0) yy += ylabel;
2267 textaxis->SetTitle(chtemp);
2268 Double_t u = gPad->GetX1() + xx*(gPad->GetX2() - gPad->GetX1());
2269 Double_t v = gPad->GetY1() + yy*(gPad->GetY2() - gPad->GetY1());
2271 textaxis->GetBoundingBox(wi, hi); wi=(UInt_t)(wi*1.3); hi=(UInt_t)(hi*1.3);
2272 xi1 = gPad->XtoAbsPixel(u);
2273 yi1 = gPad->YtoAbsPixel(v);
2274 firstintlab = kFALSE;
2276 typolabel.ReplaceAll(
"-",
"#minus");
2277 textaxis->PaintLatex(u,v,0,textaxis->GetTextSize(),typolabel.Data());
2279 xi2 = gPad->XtoAbsPixel(u);
2280 yi2 = gPad->YtoAbsPixel(v);
2281 xl = TMath::Min(xi1,xi2);
2282 xh = TMath::Max(xi1,xi2);
2283 if ((x0 == x1 && yi1-hi <= yi2) || (y0 == y1 && xl+wi >= xh)){
2288 textaxis->GetBoundingBox(wi, hi); wi=(UInt_t)(wi*1.3); hi=(UInt_t)(hi*1.3);
2290 typolabel.ReplaceAll(
"-",
"#minus");
2291 textaxis->PaintLatex(u,v,0,textaxis->GetTextSize(),typolabel.Data());
2297 if (optionGrid && nbinin <= 5 && ndiv > 100) {
2298 Rotate(xone,0,cosphi,sinphi,x0,y0,xpl2, ypl2);
2299 Rotate(xone,grid_side*gridlength,cosphi,sinphi,x0,y0, xpl1,ypl1);
2300 linegrid->PaintLineNDC(xpl1, ypl1, xpl2, ypl2);
2306 Int_t dummy = 0;
if (dummy) { }
2310 if (!drawGridOnly && strlen(GetTitle())) {
2311 textaxis->SetTextSize (GetTitleSize());
2312 charheight = GetTitleSize();
2313 if ((GetTextFont() % 10) > 2) {
2314 charheight = charheight/gPad->GetWh();
2318 if (toffset) ylabel = xlside*charheight+toffset;
2319 else ylabel = xlside*1.6*charheight;
2321 ylabel = xlside*1.6*charheight*toffset;
2324 ylabel = xlside*1.3*charheight*toffset;
2327 if (toffset == 0.) toffset = gStyle->GetTitleOffset(
"X");
2328 ylabel = xlside*1.6*charheight*toffset;
2331 if (TestBit(TAxis::kCenterTitle)) axispos = 0.5*axis_length;
2332 else axispos = axis_length;
2333 if (TestBit(TAxis::kRotateTitle)) {
2335 if (TestBit(TAxis::kCenterTitle)) textaxis->SetTextAlign(22);
2336 else textaxis->SetTextAlign(12);
2338 if (TestBit(TAxis::kCenterTitle)) textaxis->SetTextAlign(22);
2339 else textaxis->SetTextAlign(32);
2344 if (TestBit(TAxis::kCenterTitle)) textaxis->SetTextAlign(22);
2345 else textaxis->SetTextAlign(32);
2347 if (TestBit(TAxis::kCenterTitle)) textaxis->SetTextAlign(22);
2348 else textaxis->SetTextAlign(12);
2351 Rotate(axispos,ylabel,cosphi,sinphi,x0,y0,xpl1,ypl1);
2352 textaxis->SetTextColor(TitleColor);
2353 textaxis->SetTextFont(TitleFont);
2354 textaxis->PaintLatex(gPad->GetX1() + xpl1*(gPad->GetX2() - gPad->GetX1()),
2355 gPad->GetY1() + ypl1*(gPad->GetY2() - gPad->GetY1()),
2362 if (optionGrid)
delete linegrid;
2376 void TGaxis::AdjustBinSize(Double_t A1, Double_t A2, Int_t nold
2377 ,Double_t &binLow, Double_t &binHigh, Int_t &nbins, Double_t &binWidth)
2380 binWidth = TMath::Abs(A2-A1)/Double_t(nold);
2381 if (binWidth <= 1) { binWidth = 1; binLow = int(A1); }
2383 Int_t width = int(binWidth/5) + 1;
2385 binLow = int(A1/binWidth)*binWidth;
2391 for (Int_t ic=0; ic<1000; ic++) {
2392 Double_t rbl = binLow/binWidth;
2393 Int_t ibl = int(binLow/binWidth);
2394 if ( (rbl-ibl) == 0 || ic > width) { binLow -= 5;
break;}
2400 Double_t xb = binLow;
2401 while (xb <= binHigh) {
2405 binHigh = xb - binWidth;
2411 void TGaxis::LabelsLimits(
const char *label, Int_t &first, Int_t &last)
2413 last = strlen(label)-1;
2414 for (Int_t i=0; i<=last; i++) {
2415 if (strchr(
"1234567890-+.", label[i]) ) { first = i;
return; }
2417 Error(
"LabelsLimits",
"attempt to draw a blank label");
2423 void TGaxis::Rotate(Double_t X, Double_t Y, Double_t CFI, Double_t SFI
2424 ,Double_t XT, Double_t YT, Double_t &U, Double_t &V)
2433 void TGaxis::SavePrimitive(std::ostream &out, Option_t * )
2436 if (gROOT->ClassSaved(TGaxis::Class())) {
2441 out<<
"gaxis = new TGaxis("<<fX1<<
","<<fY1<<
","<<fX2<<
","<<fY2
2442 <<
","<<fWmin<<
","<<fWmax<<
","<<fNdiv<<
","<<quote<<fChopt.Data()<<quote<<
");"<<std::endl;
2443 out<<
" gaxis->SetLabelOffset("<<GetLabelOffset()<<
");"<<std::endl;
2444 out<<
" gaxis->SetLabelSize("<<GetLabelSize()<<
");"<<std::endl;
2445 out<<
" gaxis->SetTickSize("<<GetTickSize()<<
");"<<std::endl;
2446 out<<
" gaxis->SetGridLength("<<GetGridLength()<<
");"<<std::endl;
2447 out<<
" gaxis->SetTitleOffset("<<GetTitleOffset()<<
");"<<std::endl;
2448 out<<
" gaxis->SetTitleSize("<<GetTitleSize()<<
");"<<std::endl;
2449 out<<
" gaxis->SetTitleColor("<<GetTextColor()<<
");"<<std::endl;
2450 out<<
" gaxis->SetTitleFont("<<GetTextFont()<<
");"<<std::endl;
2452 if (strlen(GetName())) {
2453 out<<
" gaxis->SetName("<<quote<<GetName()<<quote<<
");"<<std::endl;
2455 if (strlen(GetTitle())) {
2456 out<<
" gaxis->SetTitle("<<quote<<GetTitle()<<quote<<
");"<<std::endl;
2459 if (fLabelColor != 1) {
2460 if (fLabelColor > 228) {
2461 TColor::SaveColor(out, fLabelColor);
2462 out<<
" gaxis->SetLabelColor(ci);" << std::endl;
2464 out<<
" gaxis->SetLabelColor("<<GetLabelColor()<<
");"<<std::endl;
2466 if (fLineColor != 1) {
2467 if (fLineColor > 228) {
2468 TColor::SaveColor(out, fLineColor);
2469 out<<
" gaxis->SetLineColor(ci);" << std::endl;
2471 out<<
" gaxis->SetLineColor("<<GetLineColor()<<
");"<<std::endl;
2473 if (fLineStyle != 1) {
2474 out<<
" gaxis->SetLineStyle("<<GetLineStyle()<<
");"<<std::endl;
2476 if (fLineWidth != 1) {
2477 out<<
" gaxis->SetLineWidth("<<GetLineWidth()<<
");"<<std::endl;
2479 if (fLabelFont != 62) {
2480 out<<
" gaxis->SetLabelFont("<<GetLabelFont()<<
");"<<std::endl;
2482 if (TestBit(TAxis::kMoreLogLabels)) {
2483 out<<
" gaxis->SetMoreLogLabels();"<<std::endl;
2485 if (TestBit(TAxis::kNoExponent)) {
2486 out<<
" gaxis->SetNoExponent();"<<std::endl;
2489 out<<
" gaxis->Draw();"<<std::endl;
2499 void TGaxis::SetDecimals(Bool_t dot)
2501 if (dot) SetBit(TAxis::kDecimals);
2502 else ResetBit(TAxis::kDecimals);
2508 void TGaxis::SetFunction(
const char *funcname)
2510 fFunctionName = funcname;
2515 fFunction = (TF1*)gROOT->GetFunction(funcname);
2517 Error(
"SetFunction",
"unknown function: %s", funcname);
2519 fWmin = fFunction->GetXmin();
2520 fWmax = fFunction->GetXmax();
2561 void TGaxis::ChangeLabel(Int_t labNum, Double_t labAngle, Double_t labSize,
2562 Int_t labAlign, Int_t labColor, Int_t labFont,
2566 if (!fModLabs) fModLabs =
new TList();
2576 TAxisModLab *ml =
new TAxisModLab();
2577 ml->SetLabNum(labNum);
2578 ml->SetAngle(labAngle);
2579 ml->SetSize(labSize);
2580 ml->SetAlign(labAlign);
2581 ml->SetColor(labColor);
2582 ml->SetFont(labFont);
2583 ml->SetText(labText);
2585 fModLabs->Add((TObject*)ml);
2596 static Double_t SavedTextAngle;
2597 static Double_t SavedTextSize;
2598 static Int_t SavedTextAlign;
2599 static Int_t SavedTextColor;
2600 static Int_t SavedTextFont;;
2602 void TGaxis::ChangeLabelAttributes(Int_t i, Int_t nlabels, TLatex* t,
char* c)
2604 if (!fModLabs)
return;
2606 TIter next(fModLabs);
2609 while ( (ml = (TAxisModLab*)next()) ) {
2610 SavedTextAngle = t->GetTextAngle();
2611 SavedTextSize = t->GetTextSize();
2612 SavedTextAlign = t->GetTextAlign();
2613 SavedTextColor = t->GetTextColor();
2614 SavedTextFont = t->GetTextFont();
2615 labNum = ml->GetLabNum();
2616 if (labNum < 0) labNum = nlabels + labNum + 2;
2618 if (ml->GetAngle()>=0.) t->SetTextAngle(ml->GetAngle());
2619 if (ml->GetSize()>=0.) t->SetTextSize(ml->GetSize());
2620 if (ml->GetAlign()>0) t->SetTextAlign(ml->GetAlign());
2621 if (ml->GetColor()>=0) t->SetTextColor(ml->GetColor());
2622 if (ml->GetFont()>0) t->SetTextFont(ml->GetFont());
2623 if (!(ml->GetText().IsNull())) strncpy(c, (ml->GetText()).Data(), 256);
2633 void TGaxis::ResetLabelAttributes(TLatex* t)
2635 t->SetTextAngle(SavedTextAngle);
2636 t->SetTextSize(SavedTextSize);
2637 t->SetTextAlign(SavedTextAlign);
2638 t->SetTextColor(SavedTextColor);
2639 t->SetTextFont(SavedTextFont);
2649 void TGaxis::SetMaxDigits(Int_t maxd)
2652 if (maxd < 1) fgMaxDigits = 1;
2658 void TGaxis::SetName(
const char *name)
2668 void TGaxis::SetMoreLogLabels(Bool_t more)
2670 if (more) SetBit(TAxis::kMoreLogLabels);
2671 else ResetBit(TAxis::kMoreLogLabels);
2679 void TGaxis::SetNoExponent(Bool_t noExponent)
2681 if (noExponent) SetBit(TAxis::kNoExponent);
2682 else ResetBit(TAxis::kNoExponent);
2688 void TGaxis::SetOption(Option_t *option)
2696 void TGaxis::SetTitle(
const char *title)
2723 void TGaxis::SetTimeFormat(
const char *tformat)
2725 TString timeformat = tformat;
2727 if (timeformat.Index(
"%F")>=0 || timeformat.IsNull()) {
2728 fTimeFormat = timeformat;
2732 Int_t idF = fTimeFormat.Index(
"%F");
2734 Int_t lnF = fTimeFormat.Length();
2735 TString stringtimeoffset = fTimeFormat(idF,lnF);
2736 fTimeFormat = tformat;
2737 fTimeFormat.Append(stringtimeoffset);
2739 fTimeFormat = tformat;
2740 SetTimeOffset(gStyle->GetTimeOffset());
2747 void TGaxis::SetTimeOffset(Double_t toffset, Option_t *option)
2749 TString opt = option;
2755 Int_t idF = fTimeFormat.Index(
"%F");
2756 if (idF>=0) fTimeFormat.Remove(idF);
2757 fTimeFormat.Append(
"%F");
2759 timeoff = (time_t)((Long_t)(toffset));
2763 utctis = gmtime(&timeoff);
2765 if (utctis !=
nullptr) {
2766 strftime(tmp, 20,
"%Y-%m-%d %H:%M:%S",utctis);
2767 fTimeFormat.Append(tmp);
2769 fTimeFormat.Append(
"1970-01-01 00:00:00");
2773 Double_t ds = toffset-(Int_t)toffset;
2774 snprintf(tmp,20,
"s%g",ds);
2775 fTimeFormat.Append(tmp);
2778 if (opt.Contains(
"gmt")) fTimeFormat.Append(
" GMT");
2787 void TGaxis::SetExponentOffset(Float_t xoff, Float_t yoff, Option_t *axis)
2792 if (opt.Contains(
"x")) {
2793 fXAxisExpXOffset = xoff;
2794 fXAxisExpYOffset = yoff;
2796 if (opt.Contains(
"y")) {
2797 fYAxisExpXOffset = xoff;
2798 fYAxisExpYOffset = yoff;
2805 void TGaxis::Streamer(TBuffer &R__b)
2807 if (R__b.IsReading()) {
2809 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
2811 R__b.ReadClassBuffer(TGaxis::Class(),
this, R__v, R__s, R__c);
2815 TLine::Streamer(R__b);
2816 TAttText::Streamer(R__b);
2820 R__b >> fGridLength;
2822 R__b >> fLabelOffset;
2824 R__b >> fTitleOffset;
2828 R__b >> fLabelColor;
2830 fChopt.Streamer(R__b);
2831 fName.Streamer(R__b);
2832 fTitle.Streamer(R__b);
2833 fTimeFormat.Streamer(R__b);
2835 fFunctionName.Streamer(R__b);
2836 fFunction = (TF1*)gROOT->GetFunction(fFunctionName.Data());
2838 R__b.CheckByteCount(R__s, R__c, TGaxis::IsA());
2842 R__b.WriteClassBuffer(TGaxis::Class(),
this);