Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TAxis.cxx
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Rene Brun 12/12/94
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TAxis.h"
13#include "TVirtualPad.h"
14#include "TStyle.h"
15#include "TError.h"
16#include "THashList.h"
17#include "TList.h"
18#include "TAxisModLab.h"
19#include "TH1.h"
20#include "TObjString.h"
21#include "TDatime.h"
22#include "TTimeStamp.h"
23#include "TBuffer.h"
24#include "TMath.h"
25#include "THLimitsFinder.h"
26#include "strlcpy.h"
27#include "snprintf.h"
28
29#include <iostream>
30#include <ctime>
31#include <cassert>
32
34
35////////////////////////////////////////////////////////////////////////////////
36/** \class TAxis
37 \ingroup Histograms
38 \brief Class to manage histogram axis
39
40This class manages histogram axis. It is referenced by TH1 and TGraph.
41To make a graphical representation of an histogram axis, this class
42references the TGaxis class. TAxis supports axis with fixed or variable bin sizes.
43Labels may be associated to individual bins.
44See examples of various axis representations drawn by class TGaxis.
45*///////////////////////////////////////////////////////////////////////////////
46
47////////////////////////////////////////////////////////////////////////////////
48/// Default constructor.
49
51{
52 fNbins = 1;
53 fXmin = 0;
54 fXmax = 1;
55 fFirst = 0;
56 fLast = 0;
57 fBits2 = 0;
58 fTimeDisplay = false;
59}
60
61////////////////////////////////////////////////////////////////////////////////
62/// Axis constructor for axis with fix bin size
63
65{
66 Set(nbins,xlow,xup);
67}
68
69////////////////////////////////////////////////////////////////////////////////
70/// Axis constructor for variable bin size
71
72TAxis::TAxis(Int_t nbins,const Double_t *xbins)
73{
74 Set(nbins,xbins);
75}
76
77TAxis::TAxis(std::vector<double> const &bins):
78 TAxis(bins.size()-1, bins.data())
79{}
81////////////////////////////////////////////////////////////////////////////////
82/// Destructor.
85{
86 if (fLabels) {
87 fLabels->Delete();
88 delete fLabels;
89 fLabels = nullptr;
90 }
91 if (fModLabs) {
93 delete fModLabs;
94 fModLabs = nullptr;
95 }
96}
97
98////////////////////////////////////////////////////////////////////////////////
99/// Copy constructor.
100
101TAxis::TAxis(const TAxis &axis) : TNamed(axis), TAttAxis(axis)
102{
103 fParent = nullptr;
104 fLabels = nullptr;
105 fModLabs = nullptr;
106
107 axis.TAxis::Copy(*this);
108}
109
110////////////////////////////////////////////////////////////////////////////////
111/// Assignment operator.
112
114{
115 if (this != &axis)
116 axis.TAxis::Copy(*this);
117 return *this;
118}
119
120
121////////////////////////////////////////////////////////////////////////////////
122/// Choose a reasonable time format from the coordinates in the active pad
123/// and the number of divisions in this axis
124/// If orientation = "X", the horizontal axis of the pad will be used for ref.
125/// If orientation = "Y", the vertical axis of the pad will be used for ref.
126
127const char *TAxis::ChooseTimeFormat(Double_t axislength)
128{
129 const char *formatstr = nullptr;
130 Int_t reasformat = 0;
131 Int_t ndiv,nx1,nx2,n;
132 Double_t awidth;
134
135 if (!axislength) {
136 length = gPad->GetUxmax() - gPad->GetUxmin();
137 } else {
138 length = axislength;
139 }
140
141 ndiv = GetNdivisions();
142 if (ndiv > 1000) {
143 nx2 = ndiv/100;
144 nx1 = TMath::Max(1, ndiv%100);
145 ndiv = 100*nx2 + Int_t(Double_t(nx1)*gPad->GetAbsWNDC());
146 }
147 ndiv = TMath::Abs(ndiv);
148 n = ndiv - (ndiv/100)*100;
149 awidth = length/n;
150
151// width in seconds ?
152 if (awidth>=.5) {
153 reasformat = 1;
154// width in minutes ?
155 if (awidth>=30) {
156 awidth /= 60; reasformat = 2;
157// width in hours ?
158 if (awidth>=30) {
159 awidth /=60; reasformat = 3;
160// width in days ?
161 if (awidth>=12) {
162 awidth /= 24; reasformat = 4;
163// width in months ?
164 if (awidth>=15.218425) {
165 awidth /= 30.43685; reasformat = 5;
166// width in years ?
167 if (awidth>=6) {
168 awidth /= 12; reasformat = 6;
169 if (awidth>=2) {
170 awidth /= 12; reasformat = 7;
171 }
172 }
173 }
174 }
175 }
176 }
177 }
178// set reasonable format
179 switch (reasformat) {
180 case 0:
181 formatstr = "%S";
182 break;
183 case 1:
184 formatstr = "%Mm%S";
185 break;
186 case 2:
187 formatstr = "%Hh%M";
188 break;
189 case 3:
190 formatstr = "%d-%Hh";
191 break;
192 case 4:
193 formatstr = "%d/%m";
194 break;
195 case 5:
196 formatstr = "%d/%m/%y";
197 break;
198 case 6:
199 formatstr = "%d/%m/%y";
200 break;
201 case 7:
202 formatstr = "%m/%y";
203 break;
204 }
205 return formatstr;
206}
207
208////////////////////////////////////////////////////////////////////////////////
209/// Copy axis structure to another axis
210
211void TAxis::Copy(TObject &obj) const
212{
213 TAxis &axis = static_cast<TAxis &>(obj);
214 TNamed::Copy(axis);
215 TAttAxis::Copy(axis);
216 axis.fNbins = fNbins;
217 axis.fXmin = fXmin;
218 axis.fXmax = fXmax;
219 axis.fFirst = fFirst;
220 axis.fLast = fLast;
221 axis.fBits2 = fBits2;
222 fXbins.Copy(axis.fXbins);
225 axis.fParent = fParent;
226 if (axis.fLabels) {
227 axis.fLabels->Delete();
228 delete axis.fLabels;
229 axis.fLabels = nullptr;
230 }
231 if (fLabels) {
232 //Properly handle case where not all bins have labels
233 axis.fLabels = new THashList(axis.fNbins, 3);
234 TIter next(fLabels);
235 while(auto label = (TObjString *)next()) {
236 TObjString *copyLabel = new TObjString(*label);
237 axis.fLabels->Add(copyLabel);
238 copyLabel->SetUniqueID(label->GetUniqueID());
239 }
240 }
241 if (axis.fModLabs) {
242 axis.fModLabs->Delete();
243 delete axis.fModLabs;
244 axis.fModLabs = nullptr;
245 }
246 if (fModLabs) {
247 axis.fModLabs = new TList();
248 TIter next(fModLabs);
249 while(auto modlabel = (TAxisModLab *)next()) {
250 TAxisModLab *copyModLabel = new TAxisModLab(*modlabel);
251 axis.fModLabs->Add(copyModLabel);
252 copyModLabel->SetUniqueID(modlabel->GetUniqueID());
253 }
254 }
255}
256
257////////////////////////////////////////////////////////////////////////////////
258/// Compute distance from point px,py to an axis
259
261{
262 return 9999;
263}
264
265////////////////////////////////////////////////////////////////////////////////
266/// Execute action corresponding to one event
267///
268/// This member function is called when an axis is clicked with the locator.
269/// The axis range is set between the position where the mouse is pressed
270/// and the position where it is released.
271/// If the mouse position is outside the current axis range when it is released
272/// the axis is unzoomed with the corresponding proportions.
273/// Note that the mouse does not need to be in the pad or even canvas
274/// when it is released.
275
277{
278 if (!gPad) return;
279 gPad->ExecuteEventAxis(event,px,py,this);
280}
281
282////////////////////////////////////////////////////////////////////////////////
283/// Find bin number corresponding to abscissa x. NOTE: this method does not work with alphanumeric bins !!!
284///
285/// If x is underflow or overflow, attempt to extend the axis if TAxis::kCanExtend is true.
286/// Otherwise, return 0 or fNbins+1.
287
289{
290 Int_t bin;
291 // NOTE: This should not be allowed for Alphanumeric histograms,
292 // but it is heavily used (legacy) in the TTreePlayer to fill alphanumeric histograms.
293 // but in case of alphanumeric do-not extend the axis. It makes no sense
294 if (IsAlphanumeric() && gDebug) Info("FindBin","Numeric query on alphanumeric axis - Sorting the bins or extending the axes / rebinning can alter the correspondence between the label and the bin interval.");
295 if (x < fXmin) { //*-* underflow
296 bin = 0;
297 if (fParent == nullptr) return bin;
298 if (!CanExtend() || IsAlphanumeric() ) return bin;
299 ((TH1*)fParent)->ExtendAxis(x,this);
300 return FindFixBin(x);
301 } else if ( !(x < fXmax)) { //*-* overflow (note the way to catch NaN)
302 bin = fNbins+1;
303 if (fParent == nullptr) return bin;
304 if (!CanExtend() || IsAlphanumeric() ) return bin;
305 ((TH1*)fParent)->ExtendAxis(x,this);
306 return FindFixBin(x);
307 } else {
308 if (!fXbins.fN) { //*-* fix bins
309 bin = 1 + int (fNbins*(x-fXmin)/(fXmax-fXmin) );
310 } else { //*-* variable bin sizes
311 //for (bin =1; x >= fXbins.fArray[bin]; bin++);
313 }
314 }
315 return bin;
316}
317
318////////////////////////////////////////////////////////////////////////////////
319/// Find bin number with label.
320/// If the List of labels does not exist create it and make the axis alphanumeric
321/// If one wants just to add a single label- just call TAxis::SetBinLabel
322/// If label is not in the list of labels do the following depending on the
323/// bit TAxis::kCanExtend; of the axis.
324/// - if the bit is set add the new label and if the number of labels exceeds
325/// the number of bins, double the number of bins via TH1::LabelsInflate
326/// - if the bit is not set and the histogram has labels in each bin
327/// set the bit automatically and consider the histogram as alphanumeric
328/// if histogram has only some bins with labels then the histogram is not
329/// consider alphanumeric and return -1
330///
331/// -1 is returned only when the Axis has no parent histogram
332
333Int_t TAxis::FindBin(const char *label)
334{
335 //create list of labels if it does not exist yet
336 if (!fLabels) {
337 if (!fParent) return -1;
338 fLabels = new THashList(fNbins,3);
339 // we set the axis alphanumeric
340 // when list of labels does not exist
341 // do we want to do this also when histogram is not empty ?????
342 if (CanBeAlphanumeric() ) {
345 if (fXmax <= fXmin) {
346 //L.M. Dec 2010 in case of no min and max specified use 0 ->NBINS
347 fXmin = 0;
348 fXmax = fNbins;
349 }
350 }
351 }
352
353 // search for label in the existing list and return it if it exists
354 TObjString *obj = (TObjString*)fLabels->FindObject(label);
355 if (obj) return (Int_t)obj->GetUniqueID();
356
357 // if labels is not in the list and we have already labels
358 if (!IsAlphanumeric()) {
359 // if bins without labels exist or if the axis cannot be set to alphanumeric
361 Info("FindBin","Label %s is not in the list and the axis is not alphanumeric - ignore it",label);
362 return -1;
363 }
364 else {
365 Info("FindBin","Label %s not in the list. It will be added to the histogram",label);
368 }
369 }
370
371 //Not yet in the list. Can we extend the axis ?
372 assert ( CanExtend() && IsAlphanumeric() );
373 // {
374 // if (gDebug>0)
375 // Info("FindBin","Label %s is not in the list and the axis cannot be extended - the entry will be added in the underflow bin",label);
376 // return 0;
377 // }
378
380
381 //may be we have to resize the histogram (doubling number of channels)
382 if (n >= fNbins) ((TH1*)fParent)->LabelsInflate(GetName());
383
384 //add new label to the list: assign bin number
385 obj = new TObjString(label);
386 fLabels->Add(obj);
387 obj->SetUniqueID(n+1);
388 return n+1;
389}
390
391////////////////////////////////////////////////////////////////////////////////
392/// Find bin number with label.
393/// If the List of labels does not exist or the label does not exist just return -1 .
394/// Do not attempt to modify the axis. This is different than FindBin
395
396Int_t TAxis::FindFixBin(const char *label) const
397{
398 //create list of labels if it does not exist yet
399 if (!fLabels) return -1;
400
401 // search for label in the existing list and return it if it exists
402 TObjString *obj = (TObjString*)fLabels->FindObject(label);
403 if (obj) return (Int_t)obj->GetUniqueID();
404 return -1;
405}
406
407
408////////////////////////////////////////////////////////////////////////////////
409/// Find bin number corresponding to abscissa x
410///
411/// Identical to TAxis::FindBin except that if x is an underflow/overflow
412/// no attempt is made to extend the axis.
413
415{
416 Int_t bin;
417 if (x < fXmin) { //*-* underflow
418 bin = 0;
419 } else if ( !(x < fXmax)) { //*-* overflow (note the way to catch NaN
420 bin = fNbins+1;
421 } else {
422 if (!fXbins.fN) { //*-* fix bins
423 bin = 1 + int (fNbins*(x-fXmin)/(fXmax-fXmin) );
424 } else { //*-* variable bin sizes
425// for (bin =1; x >= fXbins.fArray[bin]; bin++);
427 }
428 }
429 return bin;
430}
431
432////////////////////////////////////////////////////////////////////////////////
433/// Return label for bin
434
435const char *TAxis::GetBinLabel(Int_t bin) const
436{
437 if (!fLabels) return "";
438 if (bin <= 0 || bin > fNbins) return "";
439 TIter next(fLabels);
440 TObjString *obj;
441 while ((obj=(TObjString*)next())) {
442 Int_t binid = (Int_t)obj->GetUniqueID();
443 if (binid == bin) return obj->GetName();
444 }
445 return "";
446}
447
448////////////////////////////////////////////////////////////////////////////////
449/// Return first bin on the axis
450/// i.e. 1 if no range defined
451/// NOTE: in some cases a zero is returned (see TAxis::SetRange)
452
454{
455 if (!TestBit(kAxisRange)) return 1;
456 return fFirst;
457}
458
459////////////////////////////////////////////////////////////////////////////////
460/// Return last bin on the axis
461/// i.e. fNbins if no range defined
462/// NOTE: in some cases a zero is returned (see TAxis::SetRange)
463
465{
466 if (!TestBit(kAxisRange)) return fNbins;
467 return fLast;
468}
469
470////////////////////////////////////////////////////////////////////////////////
471/// Return center of bin
472
474{
475 Double_t binwidth;
476 if (!fXbins.fN || bin<1 || bin>fNbins) {
477 binwidth = (fXmax - fXmin) / Double_t(fNbins);
478 return fXmin + (bin-1) * binwidth + 0.5*binwidth;
479 } else {
480 binwidth = fXbins.fArray[bin] - fXbins.fArray[bin-1];
481 return fXbins.fArray[bin-1] + 0.5*binwidth;
482 }
483}
484
485////////////////////////////////////////////////////////////////////////////////
486/// Return center of bin in log
487/// With a log-equidistant binning for a bin with low and up edges, the mean is :
488/// 0.5*(ln low + ln up) i.e. sqrt(low*up) in logx (e.g. sqrt(10^0*10^2) = 10).
489/// Imagine a bin with low=1 and up=100 :
490/// - the center in lin is (100-1)/2=50.5
491/// - the center in log would be sqrt(1*100)=10 (!=log(50.5))
492///
493/// NB: if the low edge of the bin is negative, the function returns the bin center
494/// as computed by TAxis::GetBinCenter
495
497{
498 Double_t low,up;
499 if (!fXbins.fN || bin<1 || bin>fNbins) {
500 Double_t binwidth = (fXmax - fXmin) / Double_t(fNbins);
501 low = fXmin + (bin-1) * binwidth;
502 up = low+binwidth;
503 } else {
504 low = fXbins.fArray[bin-1];
505 up = fXbins.fArray[bin];
506 }
507 if (low <=0 ) return GetBinCenter(bin);
508 return TMath::Sqrt(low*up);
509}
510////////////////////////////////////////////////////////////////////////////////
511/// Return low edge of bin
512
514{
515 if (fXbins.fN && bin > 0 && bin <=fNbins) return fXbins.fArray[bin-1];
516 Double_t binwidth = (fXmax - fXmin) / Double_t(fNbins);
517 return fXmin + (bin-1) * binwidth;
518}
519
520////////////////////////////////////////////////////////////////////////////////
521/// Return up edge of bin
522
524{
525 if (!fXbins.fN || bin < 1 || bin>fNbins) {
526 Double_t binwidth = (fXmax - fXmin) / Double_t(fNbins);
527 return fXmin + bin*binwidth;
528 }
529 return fXbins.fArray[bin];
530}
531
532////////////////////////////////////////////////////////////////////////////////
533/// Return bin width
534///
535/// If `bin > fNbins` (overflow bin) or `bin < 1` (underflow bin), the returned bin width is `(fXmax - fXmin) / fNbins`.
536
538{
539 if (fNbins <= 0) return 0;
540 if (fXbins.fN <= 0 || bin >fNbins || bin <1)
541 return (fXmax - fXmin) / Double_t(fNbins);
542 return fXbins.fArray[bin] - fXbins.fArray[bin-1];
543}
544
545
546////////////////////////////////////////////////////////////////////////////////
547/// Return an array with the center of all bins
548
549void TAxis::GetCenter(Double_t *center) const
550{
551 for (Int_t bin = 1; bin <= fNbins; bin++)
552 *(center + bin - 1) = GetBinCenter(bin);
553}
554
555////////////////////////////////////////////////////////////////////////////////
556/// Return an array with the low edge of all bins
557
559{
560 for (Int_t bin = 1; bin <= fNbins; bin++)
561 *(edge + bin - 1) = GetBinLowEdge(bin);
562}
563
564////////////////////////////////////////////////////////////////////////////////
565/// Return the number of axis labels.
566///
567/// It is sometimes useful to know the number of labels on an axis. For instance
568/// when changing the labels with TAxis::ChangeLabel. The number of labels is equal
569/// to `the_number_of_divisions + 1`. By default the number of divisions is
570/// optimised to show a coherent labeling of the main tick marks. After optimisation the
571/// real number of divisions will be smaller or equal to number of divisions requested.
572/// In order to turn off the labeling optimization, it is enough to give a negative
573/// number of divisions to TAttAxis::SetNdivisions. The absolute value of this number will be use as
574/// the exact number of divisions. This method takes the two cases (optimised or not) into
575/// account.
576
578{
579 if (fNdivisions > 0) {
580 Int_t divxo = 0;
581 Double_t x1o = 0.;
582 Double_t x2o = 0.;
583 Double_t bwx = 0.;
584 THLimitsFinder::Optimize(fXmin, fXmax,fNdivisions%100,x1o,x2o,divxo,bwx,"");
585 return divxo+1;
586 } else {
587 Int_t divx = -fNdivisions;
588 return divx%100+1;
589 }
590}
591
592////////////////////////////////////////////////////////////////////////////////
593/// Return *only* the time format from the string fTimeFormat
594
595const char *TAxis::GetTimeFormatOnly() const
596{
597 static TString timeformat;
598 Int_t idF = fTimeFormat.Index("%F");
599 if (idF>=0) {
600 timeformat = fTimeFormat(0,idF);
601 } else {
602 timeformat = fTimeFormat;
603 }
604 return timeformat.Data();
605}
606
607////////////////////////////////////////////////////////////////////////////////
608/// Return the time offset in GMT.
609
611
612 Int_t idF = fTimeFormat.Index("%F")+2;
613 if (idF<2) {
614 Warning("GetGMTimeOffset","Time format is not set!");
615 return 0;
616 }
617 TString stime=fTimeFormat(idF,19);
618 if (stime.Length() != 19) {
619 Warning("GetGMTimeOffset","Bad time format!");
620 return 0;
621 }
622
623 TDatime datime(stime.Data());
624 return datime.Convert(kTRUE); // Convert to unix gmt time
625}
626
627////////////////////////////////////////////////////////////////////////////////
628/// Return the ticks option (see SetTicks)
629
630const char *TAxis::GetTicks() const
631{
632 if (TestBit(kTickPlus) && TestBit(kTickMinus)) return "+-";
633 if (TestBit(kTickMinus)) return "-";
634 if (TestBit(kTickPlus)) return "+";
635 return "";
636}
637
638////////////////////////////////////////////////////////////////////////////////
639/// This helper function checks if there is a bin without a label
640/// if all bins have labels, the axis can / will become alphanumeric
641
643{
644 return fLabels->GetSize() != fNbins;
645}
646
647////////////////////////////////////////////////////////////////////////////////
648/// Set option(s) to draw axis with labels
649/// option can be:
650/// - "a" sort by alphabetic order
651/// - ">" sort by decreasing values
652/// - "<" sort by increasing values
653/// - "h" draw labels horizontal
654/// - "v" draw labels vertical
655/// - "u" draw labels up (end of label right adjusted)
656/// - "d" draw labels down (start of label left adjusted)
657
659{
660 if (!fLabels) {
661 Warning("Sort","Cannot sort. No labels");
662 return;
663 }
664 TH1 *h = (TH1*)GetParent();
665 if (!h) {
666 Error("Sort","Axis has no parent");
667 return;
668 }
669
670 h->LabelsOption(option,GetName());
671}
672
673////////////////////////////////////////////////////////////////////////////////
674/// Copy axis attributes to this
675
677{
678 SetTitle(axis->GetTitle());
680 SetAxisColor(axis->GetAxisColor());
682 SetLabelFont(axis->GetLabelFont());
684 SetLabelSize(axis->GetLabelSize());
687 SetTitleSize(axis->GetTitleSize());
689 SetTitleFont(axis->GetTitleFont());
699}
700
701
702
703////////////////////////////////////////////////////////////////////////////////
704/// Save axis attributes as C++ statement(s) on output stream out
705
706void TAxis::SaveAttributes(std::ostream &out, const char *name, const char *subname)
707{
708 char quote = '"';
709 if (strlen(GetTitle())) {
710 TString t(GetTitle());
711 t.ReplaceAll("\\","\\\\");
712 out<<" "<<name<<subname<<"->SetTitle("<<quote<<t.Data()<<quote<<");"<<std::endl;
713 }
714 if (fTimeDisplay) {
715 out<<" "<<name<<subname<<"->SetTimeDisplay(1);"<<std::endl;
716 out<<" "<<name<<subname<<"->SetTimeFormat("<<quote<<GetTimeFormat()<<quote<<");"<<std::endl;
717 }
718 if (fLabels) {
719 TIter next(fLabels);
720 TObjString *obj;
721 while ((obj=(TObjString*)next())) {
722 out<<" "<<name<<subname<<"->SetBinLabel("<<obj->GetUniqueID()<<","<<quote<<obj->GetName()<<quote<<");"<<std::endl;
723 }
724 }
725
726 if (fFirst || fLast) {
727 out<<" "<<name<<subname<<"->SetRange("<<fFirst<<","<<fLast<<");"<<std::endl;
728 }
729
730 if (TestBit(kLabelsHori)) {
731 out<<" "<<name<<subname<<"->SetBit(TAxis::kLabelsHori);"<<std::endl;
732 }
733
734 if (TestBit(kLabelsVert)) {
735 out<<" "<<name<<subname<<"->SetBit(TAxis::kLabelsVert);"<<std::endl;
736 }
737
738 if (TestBit(kLabelsDown)) {
739 out<<" "<<name<<subname<<"->SetBit(TAxis::kLabelsDown);"<<std::endl;
740 }
741
742 if (TestBit(kLabelsUp)) {
743 out<<" "<<name<<subname<<"->SetBit(TAxis::kLabelsUp);"<<std::endl;
744 }
745
746 if (TestBit(kCenterLabels)) {
747 out<<" "<<name<<subname<<"->CenterLabels(true);"<<std::endl;
748 }
749
750 if (TestBit(kCenterTitle)) {
751 out<<" "<<name<<subname<<"->CenterTitle(true);"<<std::endl;
752 }
753
754 if (TestBit(kRotateTitle)) {
755 out<<" "<<name<<subname<<"->RotateTitle(true);"<<std::endl;
756 }
757
758 if (TestBit(kDecimals)) {
759 out<<" "<<name<<subname<<"->SetDecimals();"<<std::endl;
760 }
761
762 if (TestBit(kMoreLogLabels)) {
763 out<<" "<<name<<subname<<"->SetMoreLogLabels();"<<std::endl;
764 }
765
766 if (TestBit(kNoExponent)) {
767 out<<" "<<name<<subname<<"->SetNoExponent();"<<std::endl;
768 }
769 if (fModLabs) {
770 TIter next(fModLabs);
771 while (auto ml = (TAxisModLab*)next()) {
772 if (ml->GetLabNum() == 0)
773 out<<" "<<name<<subname<<"->ChangeLabelByValue("<<ml->GetLabValue()<<",";
774 else
775 out<<" "<<name<<subname<<"->ChangeLabel("<<ml->GetLabNum()<<",";
776 out<<ml->GetAngle()<<","
777 <<ml->GetSize()<<","
778 <<ml->GetAlign()<<","
779 <<ml->GetColor()<<","
780 <<ml->GetFont()<<","
781 <<quote<<ml->GetText()<<quote<<");"<<std::endl;
782 }
783 }
784 TAttAxis::SaveAttributes(out,name,subname);
785}
786
787////////////////////////////////////////////////////////////////////////////////
788/// Initialize axis with fix bins
789
790void TAxis::Set(Int_t nbins, Double_t xlow, Double_t xup)
791{
792 fNbins = nbins;
793 fXmin = xlow;
794 fXmax = xup;
795 if (!fParent) SetDefaults();
796 if (fXbins.fN > 0) fXbins.Set(0);
797}
798
799////////////////////////////////////////////////////////////////////////////////
800/// Initialize axis with variable bins
801
802void TAxis::Set(Int_t nbins, const Float_t *xbins)
803{
804 Int_t bin;
805 fNbins = nbins;
806 fXbins.Set(fNbins+1);
807 for (bin=0; bin<= fNbins; bin++)
808 fXbins.fArray[bin] = xbins[bin];
809 for (bin=1; bin<= fNbins; bin++)
810 if (fXbins.fArray[bin] < fXbins.fArray[bin-1])
811 Error("TAxis::Set", "bins must be in increasing order");
812 fXmin = fXbins.fArray[0];
814 if (!fParent) SetDefaults();
815}
816
817////////////////////////////////////////////////////////////////////////////////
818/// Initialize axis with variable bins
819
820void TAxis::Set(Int_t nbins, const Double_t *xbins)
821{
822 Int_t bin;
823 fNbins = nbins;
824 fXbins.Set(fNbins+1);
825 for (bin=0; bin<= fNbins; bin++)
826 fXbins.fArray[bin] = xbins[bin];
827 for (bin=1; bin<= fNbins; bin++)
828 if (fXbins.fArray[bin] < fXbins.fArray[bin-1])
829 Error("TAxis::Set", "bins must be in increasing order");
830 fXmin = fXbins.fArray[0];
832 if (!fParent) SetDefaults();
833}
834
835////////////////////////////////////////////////////////////////////////////////
836/// Set axis alphanumeric
837
839{
840 if (alphanumeric) fBits2 |= kAlphanumeric;
841 else fBits2 &= ~kAlphanumeric;
842
843 // clear underflow and overflow (in an alphanumeric situation they do not make sense)
844 // NOTE: using AddBinContent instead of SetBinContent in order to not change
845 // the number of entries
846 //((TH1 *)fParent)->ClearUnderflowAndOverflow();
847 // L.M. 26.1.15 Keep underflow and overflows (see ROOT-7034)
848 if (gDebug && fParent) {
849 TH1 * h = dynamic_cast<TH1*>( fParent);
850 if (!h) return;
851 double s[TH1::kNstat];
852 h->GetStats(s);
853 if (s[0] != 0. && gDebug > 0)
854 Info("SetAlphanumeric","Cannot switch axis %s of histogram %s to alphanumeric: it has non-zero content",GetName(),h->GetName());
855 }
856}
857
858
859////////////////////////////////////////////////////////////////////////////////
860/// Set axis default values (from TStyle)
861
863{
864 fFirst = 0;
865 fLast = 0;
866 fBits2 = 0;
867 char name[2];
868 strlcpy(name,GetName(),2);
869 name[1] = 0;
871 fTimeDisplay = false;
873}
874
875////////////////////////////////////////////////////////////////////////////////
876/// Set label for bin.
877/// If no label list exists, it is created. If all the bins have labels, the
878/// axis becomes alphanumeric and extendable.
879/// New labels will not be added with the Fill method but will end-up in the
880/// underflow bin. See documentation of TAxis::FindBin(const char*)
881
882void TAxis::SetBinLabel(Int_t bin, const char *label)
883{
884 if (!fLabels) fLabels = new THashList(fNbins,3);
885
886 if (bin <= 0 || bin > fNbins) {
887 Error("SetBinLabel","Illegal bin number: %d",bin);
888 return;
889 }
890
891 // Check whether this bin already has a label.
892 TIter next(fLabels);
893 TObjString *obj;
894 while ((obj=(TObjString*)next())) {
895 if ( obj->GetUniqueID()==(UInt_t)bin ) {
896 // It does. Overwrite it.
897 obj->SetString(label);
898 // LM need to rehash the labels list (see ROOT-5025)
900 return;
901 }
902 }
903 // It doesn't. Add this new label.
904 obj = new TObjString(label);
905 fLabels->Add(obj);
906 obj->SetUniqueID((UInt_t)bin);
907
908 // check for Alphanumeric case (labels for each bin)
909 if (CanBeAlphanumeric() && fLabels->GetSize() == fNbins) {
912 }
913}
914
915////////////////////////////////////////////////////////////////////////////////
916/// Search for axis modifier by index or value
917
919{
920 if (!fModLabs)
921 return nullptr;
922
923 TIter next(fModLabs);
924 while (auto ml = (TAxisModLab*)next()) {
925 if (ml->GetLabNum() != num)
926 continue;
927
928 if ((num != 0) || (TMath::Abs(v - ml->GetLabValue()) <= eps))
929 return ml;
930 }
931
932 return nullptr;
933}
934
935
936////////////////////////////////////////////////////////////////////////////////
937/// Define new text attributes for the label number "labNum". It allows to do a
938/// fine tuning of the labels. All the attributes can be changed, even the
939/// label text itself.
940///
941/// \param[in] labNum Number of the label to be changed, negative numbers start from the end
942/// \param[in] labAngle New angle value
943/// \param[in] labSize New size (0 erase the label)
944/// \param[in] labAlign New alignment value
945/// \param[in] labColor New label color
946/// \param[in] labFont New label font
947/// \param[in] labText New label text
948///
949/// #### Notes:
950///
951/// - If an attribute should not be changed just give the value "-1".
952/// - If labnum=0 the list of modified labels is reset.
953/// - To erase a label set labSize to 0.
954/// - If labText is not specified or is an empty string, the text label is not changed.
955/// - To retrieve the number of axis labels use TAxis::GetNlabels.
956
957void TAxis::ChangeLabel(Int_t labNum, Double_t labAngle, Double_t labSize,
958 Int_t labAlign, Int_t labColor, Int_t labFont,
959 const TString &labText)
960{
961 // Reset the list of modified labels.
962 if (labNum == 0) {
964 return;
965 }
966
967 if (!fModLabs) fModLabs = new TList();
968
969 TAxisModLab *ml = FindModLab(labNum);
970 if (!ml) {
971 ml = new TAxisModLab();
972 ml->SetLabNum(labNum);
973 fModLabs->Add(ml);
974 }
975
976 ml->SetAngle(labAngle);
977 ml->SetSize(labSize);
978 ml->SetAlign(labAlign);
979 ml->SetColor(labColor);
980 ml->SetFont(labFont);
981 ml->SetText(labText);
982}
983
984////////////////////////////////////////////////////////////////////////////////
985/// Define new text attributes for the label value "labValue". It allows to do a
986/// fine tuning of the labels. All the attributes can be changed, even the
987/// label text itself.
988///
989/// \param[in] labValue Axis value to be changed
990/// \param[in] labAngle New angle value
991/// \param[in] labSize New size (0 erase the label)
992/// \param[in] labAlign New alignment value
993/// \param[in] labColor New label color
994/// \param[in] labFont New label font
995/// \param[in] labText New label text
996///
997/// #### Notes:
998///
999/// - If an attribute should not be changed just give the value "-1".
1000/// - If labnum=0 the list of modified labels is reset.
1001/// - To erase a label set labSize to 0.
1002/// - If labText is not specified or is an empty string, the text label is not changed.
1003/// - To retrieve the number of axis labels use TAxis::GetNlabels.
1004
1005void TAxis::ChangeLabelByValue(Double_t labValue, Double_t labAngle, Double_t labSize,
1006 Int_t labAlign, Int_t labColor, Int_t labFont,
1007 const TString &labText)
1008{
1009 if (!fModLabs) fModLabs = new TList();
1010
1011 TAxisModLab *ml = FindModLab(0, labValue, 0.);
1012 if (!ml) {
1013 ml = new TAxisModLab();
1014 ml->SetLabValue(labValue);
1015 fModLabs->Add(ml);
1016 }
1017
1018 ml->SetAngle(labAngle);
1019 ml->SetSize(labSize);
1020 ml->SetAlign(labAlign);
1021 ml->SetColor(labColor);
1022 ml->SetFont(labFont);
1023 ml->SetText(labText);
1024}
1025
1026
1027////////////////////////////////////////////////////////////////////////////////
1028/// Set the viewing range for the axis using bin numbers.
1029///
1030/// \param first First bin of the range.
1031/// \param last Last bin of the range.
1032///
1033/// To set a range using the axis coordinates, use TAxis::SetRangeUser.
1034///
1035/// If `first == last == 0` or if `first > last` or if the range specified does
1036/// not intersect at all with the maximum available range `[0, fNbins + 1]`,
1037/// then the viewing range is reset by removing the bit TAxis::kAxisRange. In this
1038/// case, the functions TAxis::GetFirst() and TAxis::GetLast() will return 1
1039/// and fNbins.
1040///
1041/// If the range specified partially intersects with `[0, fNbins + 1]`, then the
1042/// intersection range is accepted. For instance, if `first == -2` and `last == fNbins`,
1043/// the accepted range will be `[0, fNbins]` (`fFirst = 0` and `fLast = fNbins`).
1044///
1045/// If `last > fNbins`, the overflow bin is included in the range and will be displayed during drawing.
1046/// If `first < 1`, the underflow bin is included in the range and will be displayed during drawing.
1047///
1048/// \note For historical reasons, SetRange(0,0) resets the range even though bin 0 is
1049/// technically reserved for the underflow; in order to set the range of the axis
1050/// so that it only includes the underflow, use `SetRange(-1,0)`.
1051
1052void TAxis::SetRange(Int_t first, Int_t last)
1053{
1054
1055 Int_t nCells = fNbins + 1; // bins + overflow
1056
1057 // special reset range cases
1058 if (last < first || (first < 0 && last < 0) ||
1059 (first > nCells && last > nCells) || (first == 0 && last == 0)
1060 ) {
1061 fFirst = 1;
1062 fLast = fNbins;
1063 SetBit(kAxisRange, false);
1064 } else {
1065 fFirst = std::max(first, 0);
1066 fLast = std::min(last, nCells);
1067 SetBit(kAxisRange, true);
1068 }
1069
1070}
1071
1072
1073////////////////////////////////////////////////////////////////////////////////
1074/// Set the viewing range for the axis from `ufirst` to `ulast` (in user coordinates,
1075/// that is, the "natural" axis coordinates).
1076/// To set a range using the axis bin numbers, use TAxis::SetRange.
1077///
1078/// If `ulast > fXmax`, the overflow bin is included in the range and will be displayed during drawing.
1079/// If `ufirst < fXmin`, the underflow bin is included in the range and will be displayed during drawing.
1080
1082{
1083 if (!strstr(GetName(),"xaxis")) {
1084 TH1 *hobj = (TH1*)GetParent();
1085 if (hobj &&
1086 ((hobj->GetDimension() == 2 && strstr(GetName(),"zaxis"))
1087 || (hobj->GetDimension() == 1 && strstr(GetName(),"yaxis")))) {
1088 hobj->SetMinimum(ufirst);
1089 hobj->SetMaximum(ulast);
1090 return;
1091 }
1092 }
1093 Int_t ifirst = FindFixBin(ufirst);
1094 Int_t ilast = FindFixBin(ulast);
1095 // fixes for numerical error and for https://savannah.cern.ch/bugs/index.php?99777
1096 if (GetBinUpEdge(ifirst) <= ufirst ) ifirst += 1;
1097 if (GetBinLowEdge(ilast) >= ulast ) ilast -= 1;
1098 SetRange(ifirst, ilast);
1099}
1100
1101////////////////////////////////////////////////////////////////////////////////
1102/// Set ticks orientation.
1103/// option = "+" ticks drawn on the "positive side" (default)
1104/// option = "-" ticks drawn on the "negative side"
1105/// option = "+-" ticks drawn on both sides
1106/// option = "" ticks will be drawn as whatever is defined as default. No bit is set internally.
1107
1109{
1112 if (strchr(option,'+')) SetBit(kTickPlus);
1113 if (strchr(option,'-')) SetBit(kTickMinus);
1114}
1115
1116////////////////////////////////////////////////////////////////////////////////
1117/// Change the format used for time plotting
1118///
1119/// The format string for date and time use the same options as the one used
1120/// in the standard strftime C function, i.e. :
1121/// for date :
1122///
1123/// %a abbreviated weekday name
1124/// %b abbreviated month name
1125/// %d day of the month (01-31)
1126/// %m month (01-12)
1127/// %y year without century
1128///
1129/// for time :
1130///
1131/// %H hour (24-hour clock)
1132/// %I hour (12-hour clock)
1133/// %p local equivalent of AM or PM
1134/// %M minute (00-59)
1135/// %S seconds (00-61)
1136/// %% %
1137///
1138/// This function allows also to define the time offset. It is done via %F
1139/// which should be appended at the end of the format string. The time
1140/// offset has the following format: 'yyyy-mm-dd hh:mm:ss'
1141/// Example:
1142///
1143/// h = new TH1F("Test","h",3000,0.,200000.);
1144/// h->GetXaxis()->SetTimeDisplay(1);
1145/// h->GetXaxis()->SetTimeFormat("%d\/%m\/%y%F2000-02-28 13:00:01");
1146///
1147/// This defines the time format being "dd/mm/yy" and the time offset as the
1148/// February 28th 2003 at 13:00:01
1149///
1150/// If %F is not specified, the time offset used will be the one defined by:
1151/// gStyle->SetTimeOffset. For example like that:
1152///
1153/// TDatime da(2003,02,28,12,00,00);
1154/// gStyle->SetTimeOffset(da.Convert());
1155
1156void TAxis::SetTimeFormat(const char *tformat)
1157{
1158 TString timeformat = tformat;
1159
1160 if (timeformat.Index("%F")>=0 || timeformat.IsNull()) {
1161 fTimeFormat = timeformat;
1162 return;
1163 }
1164
1165 Int_t idF = fTimeFormat.Index("%F");
1166 if (idF>=0) {
1167 Int_t lnF = fTimeFormat.Length();
1168 TString stringtimeoffset = fTimeFormat(idF,lnF);
1169 fTimeFormat = tformat;
1170 fTimeFormat.Append(stringtimeoffset);
1171 } else {
1172 fTimeFormat = tformat;
1174 }
1175}
1176
1177
1178////////////////////////////////////////////////////////////////////////////////
1179/// Change the time offset
1180/// If option = "gmt", set display mode to GMT.
1181
1183{
1184 TString opt = option;
1185 opt.ToLower();
1186
1187 char tmp[20];
1188 time_t timeoff;
1189 struct tm* utctis;
1190 Int_t idF = fTimeFormat.Index("%F");
1191 if (idF>=0) fTimeFormat.Remove(idF);
1192 fTimeFormat.Append("%F");
1193
1194 timeoff = (time_t)((Long_t)(toffset));
1195 // offset is always saved in GMT to allow file transport
1196 // to different time zones
1197 utctis = gmtime(&timeoff);
1198
1199 strftime(tmp,20,"%Y-%m-%d %H:%M:%S",utctis);
1200 fTimeFormat.Append(tmp);
1201
1202 // append the decimal part of the time offset
1203 Double_t ds = toffset-(Int_t)toffset;
1204 snprintf(tmp,20,"s%g",ds);
1205 fTimeFormat.Append(tmp);
1206
1207 // add GMT/local option
1208 if (opt.Contains("gmt")) fTimeFormat.Append(" GMT");
1209}
1210
1211
1212////////////////////////////////////////////////////////////////////////////////
1213/// Stream an object of class TAxis.
1214
1216{
1217 if (R__b.IsReading()) {
1218 UInt_t R__s, R__c;
1219 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1220 if (R__v > 5) {
1221 R__b.ReadClassBuffer(TAxis::Class(), this, R__v, R__s, R__c);
1222 return;
1223 }
1224 //====process old versions before automatic schema evolution
1225 TNamed::Streamer(R__b);
1226 TAttAxis::Streamer(R__b);
1227 R__b >> fNbins;
1228 if (R__v < 5) {
1230 R__b >> xmin; fXmin = xmin;
1231 R__b >> xmax; fXmax = xmax;
1232 Float_t *xbins = nullptr;
1233 Int_t n = R__b.ReadArray(xbins);
1234 fXbins.Set(n);
1235 for (Int_t i=0;i<n;i++) fXbins.fArray[i] = xbins[i];
1236 delete [] xbins;
1237 } else {
1238 R__b >> fXmin;
1239 R__b >> fXmax;
1240 fXbins.Streamer(R__b);
1241 }
1242 if (R__v > 2) {
1243 R__b >> fFirst;
1244 R__b >> fLast;
1245 // following lines required to repair for a bug in Root version 1.03
1246 if (fFirst < 0 || fFirst > fNbins) fFirst = 0;
1247 if (fLast < 0 || fLast > fNbins) fLast = 0;
1248 if (fLast < fFirst) { fFirst = 0; fLast = 0;}
1249 if (fFirst ==0 && fLast == 0) SetBit(kAxisRange,false);
1250 }
1251 if (R__v > 3) {
1252 R__b >> fTimeDisplay;
1253 fTimeFormat.Streamer(R__b);
1254 } else {
1255 SetTimeFormat();
1256 }
1257 R__b.CheckByteCount(R__s, R__c, TAxis::IsA());
1258 //====end of old versions
1259
1260 } else {
1261 R__b.WriteClassBuffer(TAxis::Class(),this);
1262 }
1263}
1264
1265////////////////////////////////////////////////////////////////////////////////
1266/// Reset first & last bin to the full range
1267
1269{
1270 if (!gPad) {
1271 Warning("TAxis::UnZoom","Cannot UnZoom if gPad does not exist. Did you mean to draw the TAxis first?");
1272 return;
1273 }
1274 gPad->SetView();
1275
1276 //unzoom object owning this axis
1277 SetRange(0,0);
1278 TH1 *hobj1 = (TH1*)GetParent();
1279 if (!strstr(GetName(),"xaxis")) {
1280 if (!hobj1) return;
1281 if (hobj1->GetDimension() == 2) {
1282 if (strstr(GetName(),"zaxis")) {
1283 hobj1->SetMinimum();
1284 hobj1->SetMaximum();
1285 hobj1->ResetBit(TH1::kIsZoomed);
1286 }
1287 return;
1288 }
1289 if (strcmp(hobj1->GetName(),"hframe") == 0 ) {
1290 hobj1->SetMinimum(fXmin);
1291 hobj1->SetMaximum(fXmax);
1292 } else {
1293 if (fXmin==hobj1->GetMinimum() && fXmax==hobj1->GetMaximum()) {
1294 hobj1->SetMinimum(fXmin);
1295 hobj1->SetMaximum(fXmax);
1296 } else {
1297 hobj1->SetMinimum();
1298 hobj1->SetMaximum();
1299 }
1300 hobj1->ResetBit(TH1::kIsZoomed);
1301 }
1302 }
1303 //must unzoom all histograms in the pad
1304 TIter next(gPad->GetListOfPrimitives());
1305 TObject *obj;
1306 while ((obj= next())) {
1307 if (!obj->InheritsFrom(TH1::Class())) continue;
1308 TH1 *hobj = (TH1*)obj;
1309 if (hobj == hobj1) continue;
1310 if (!strstr(GetName(),"xaxis")) {
1311 if (hobj->GetDimension() == 2) {
1312 if (strstr(GetName(),"zaxis")) {
1313 hobj->SetMinimum();
1314 hobj->SetMaximum();
1315 hobj->ResetBit(TH1::kIsZoomed);
1316 } else {
1317 hobj->GetYaxis()->SetRange(0,0);
1318 }
1319 return;
1320 }
1321 if (strcmp(hobj->GetName(),"hframe") == 0 ) {
1322 hobj->SetMinimum(fXmin);
1323 hobj->SetMaximum(fXmax);
1324 } else {
1325 hobj->SetMinimum();
1326 hobj->SetMaximum();
1327 hobj->ResetBit(TH1::kIsZoomed);
1328 }
1329 } else {
1330 hobj->GetXaxis()->SetRange(0,0);
1331 }
1332 }
1333
1334 gPad->UnZoomed();
1335}
1336
1337////////////////////////////////////////////////////////////////////////////////
1338/// Zoom out by a factor of 'factor' (default =2)
1339/// uses previous zoom factor by default
1340/// Keep center defined by 'offset' fixed
1341/// ie. -1 at left of current range, 0 in center, +1 at right
1342
1344{
1345
1346 if (factor <= 0) factor = 2;
1347 Double_t center = (GetFirst()*(1-offset) + GetLast()*(1+offset))/2.;
1348 Int_t first = int(TMath::Floor(center+(GetFirst()-center)*factor + 0.4999999));
1349 Int_t last = int(TMath::Floor(center+(GetLast() -center)*factor + 0.5000001));
1350 if (first==GetFirst() && last==GetLast()) { first--; last++; }
1351 SetRange(first,last);
1352}
#define SafeDelete(p)
Definition RConfig.hxx:533
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Definition RtypesCore.h:45
short Version_t
Definition RtypesCore.h:65
long Long_t
Definition RtypesCore.h:54
float Float_t
Definition RtypesCore.h:57
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:382
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
char name[80]
Definition TGX11.cxx:110
float xmin
float xmax
Int_t gDebug
Definition TROOT.cxx:597
R__EXTERN TStyle * gStyle
Definition TStyle.h:436
#define gPad
#define snprintf
Definition civetweb.c:1540
Double_t * fArray
Definition TArrayD.h:30
void Streamer(TBuffer &) override
Stream a TArrayD object.
Definition TArrayD.cxx:149
void Copy(TArrayD &array) const
Definition TArrayD.h:42
void Set(Int_t n) override
Set size of this array to n doubles.
Definition TArrayD.cxx:106
Int_t fN
Definition TArray.h:38
Manages histogram axis attributes.
Definition TAttAxis.h:18
virtual Color_t GetTitleColor() const
Definition TAttAxis.h:46
virtual Color_t GetLabelColor() const
Definition TAttAxis.h:38
Int_t fNdivisions
Number of divisions(10000*n3 + 100*n2 + n1)
Definition TAttAxis.h:20
virtual Int_t GetNdivisions() const
Definition TAttAxis.h:36
virtual Color_t GetAxisColor() const
Definition TAttAxis.h:37
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title.
Definition TAttAxis.cxx:298
virtual Style_t GetTitleFont() const
Definition TAttAxis.h:47
virtual Float_t GetLabelOffset() const
Definition TAttAxis.h:40
virtual void SetAxisColor(Color_t color=1, Float_t alpha=1.)
Set color of the line axis and tick marks.
Definition TAttAxis.cxx:160
virtual void SetLabelSize(Float_t size=0.04)
Set size of axis labels.
Definition TAttAxis.cxx:203
virtual Style_t GetLabelFont() const
Definition TAttAxis.h:39
virtual void SetTitleFont(Style_t font=62)
Set the title font.
Definition TAttAxis.cxx:327
virtual void SetLabelOffset(Float_t offset=0.005)
Set distance between the axis and the labels.
Definition TAttAxis.cxx:191
virtual void SetLabelFont(Style_t font=62)
Set labels' font.
Definition TAttAxis.cxx:180
virtual void SetTitleSize(Float_t size=0.04)
Set size of axis title.
Definition TAttAxis.cxx:309
virtual void SaveAttributes(std::ostream &out, const char *name, const char *subname)
Save axis attributes as C++ statement(s) on output stream out.
Definition TAttAxis.cxx:111
virtual void SetTitleColor(Color_t color=1)
Set color of axis title.
Definition TAttAxis.cxx:318
virtual Float_t GetTitleSize() const
Definition TAttAxis.h:44
virtual void Streamer(TBuffer &)
Stream an object of class TAttAxis.
Definition TAttAxis.cxx:336
virtual Float_t GetLabelSize() const
Definition TAttAxis.h:41
virtual Float_t GetTickLength() const
Definition TAttAxis.h:45
virtual void ResetAttAxis(Option_t *option="")
Reset axis attributes.
Definition TAttAxis.cxx:79
virtual Float_t GetTitleOffset() const
Definition TAttAxis.h:43
virtual void SetTickLength(Float_t length=0.03)
Set tick mark length.
Definition TAttAxis.cxx:284
virtual void SetNdivisions(Int_t n=510, Bool_t optim=kTRUE)
Set the number of divisions for this axis.
Definition TAttAxis.cxx:233
void Copy(TAttAxis &attaxis) const
Copy of the object.
Definition TAttAxis.cxx:61
virtual void SetLabelColor(Color_t color=1, Float_t alpha=1.)
Set color of labels.
Definition TAttAxis.cxx:170
TAxis helper class used to store the modified labels.
Definition TAxisModLab.h:21
void SetColor(Int_t c=-1)
Set modified label color.
void SetSize(Double_t s=-1.)
Set modified label size.
void SetFont(Int_t f=-1)
Set modified label font.
void SetText(TString t="")
Set modified label text.
void SetLabValue(Double_t v=0.)
Set modified label value.
void SetAlign(Int_t a=-1)
Set modified label alignment.
void SetLabNum(Int_t n=0)
Set modified label number.
void SetAngle(Double_t a=-1.)
Set modified label angle.
Class to manage histogram axis.
Definition TAxis.h:32
virtual void GetCenter(Double_t *center) const
Return an array with the center of all bins.
Definition TAxis.cxx:549
virtual void SetTimeOffset(Double_t toffset, Option_t *option="local")
Change the time offset If option = "gmt", set display mode to GMT.
Definition TAxis.cxx:1182
virtual void LabelsOption(Option_t *option="h")
Set option(s) to draw axis with labels option can be:
Definition TAxis.cxx:658
virtual void SetDefaults()
Set axis default values (from TStyle)
Definition TAxis.cxx:862
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
Definition TAxis.cxx:882
Int_t fLast
Last bin to display.
Definition TAxis.h:40
static TClass * Class()
void ChangeLabel(Int_t labNum=0, Double_t labAngle=-1., Double_t labSize=-1., Int_t labAlign=-1, Int_t labColor=-1, Int_t labFont=-1, const TString &labText="")
Define new text attributes for the label number "labNum".
Definition TAxis.cxx:957
Bool_t IsAlphanumeric() const
Definition TAxis.h:90
virtual void ZoomOut(Double_t factor=0, Double_t offset=0)
Zoom out by a factor of 'factor' (default =2) uses previous zoom factor by default Keep center define...
Definition TAxis.cxx:1343
const char * GetTitle() const override
Returns title of object.
Definition TAxis.h:137
Int_t GetNlabels() const
Return the number of axis labels.
Definition TAxis.cxx:577
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
Definition TAxis.cxx:473
TObject * fParent
! Object owning this axis
Definition TAxis.h:44
Double_t fXmax
Upper edge of last bin.
Definition TAxis.h:37
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to an axis.
Definition TAxis.cxx:260
Bool_t CanExtend() const
Definition TAxis.h:88
TArrayD fXbins
Bin edges array in X.
Definition TAxis.h:38
TAxis()
Default constructor.
Definition TAxis.cxx:50
UInt_t GetTimeOffset()
Return the time offset in GMT.
Definition TAxis.cxx:610
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TAxis.cxx:276
virtual void UnZoom()
Reset first & last bin to the full range.
Definition TAxis.cxx:1268
THashList * fLabels
List of labels.
Definition TAxis.h:45
void SetCanExtend(Bool_t canExtend)
Definition TAxis.h:92
void Copy(TObject &axis) const override
Copy axis structure to another axis.
Definition TAxis.cxx:211
virtual void SetTicks(Option_t *option="+")
Set ticks orientation.
Definition TAxis.cxx:1108
@ kTickMinus
Definition TAxis.h:65
@ kLabelsUp
Definition TAxis.h:75
@ kCenterTitle
Definition TAxis.h:67
@ kRotateTitle
Definition TAxis.h:69
@ kNoExponent
Definition TAxis.h:71
@ kMoreLogLabels
Definition TAxis.h:77
@ kTickPlus
Definition TAxis.h:64
@ kLabelsDown
Definition TAxis.h:74
@ kLabelsHori
Definition TAxis.h:72
@ kAxisRange
Definition TAxis.h:66
@ kDecimals
Definition TAxis.h:63
@ kCenterLabels
Bit 13 is used by TObject.
Definition TAxis.h:68
@ kLabelsVert
Definition TAxis.h:73
Bool_t fTimeDisplay
On/off displaying time values instead of numerics.
Definition TAxis.h:42
TList * fModLabs
List of modified labels.
Definition TAxis.h:46
const char * GetBinLabel(Int_t bin) const
Return label for bin.
Definition TAxis.cxx:435
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
Definition TAxis.cxx:288
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition TAxis.cxx:513
Int_t fNbins
Number of bins.
Definition TAxis.h:35
@ kAlphanumeric
Axis is alphanumeric.
Definition TAxis.h:50
Double_t fXmin
Low edge of first bin.
Definition TAxis.h:36
virtual void Set(Int_t nbins, Double_t xmin, Double_t xmax)
Initialize axis with fix bins.
Definition TAxis.cxx:790
Bool_t HasBinWithoutLabel() const
This helper function checks if there is a bin without a label if all bins have labels,...
Definition TAxis.cxx:642
TAxisModLab * FindModLab(Int_t num, Double_t v=0., Double_t eps=0.) const
Search for axis modifier by index or value.
Definition TAxis.cxx:918
virtual Int_t FindFixBin(Double_t x) const
Find bin number corresponding to abscissa x.
Definition TAxis.cxx:414
const char * ChooseTimeFormat(Double_t axislength=0)
Choose a reasonable time format from the coordinates in the active pad and the number of divisions in...
Definition TAxis.cxx:127
void SaveAttributes(std::ostream &out, const char *name, const char *subname) override
Save axis attributes as C++ statement(s) on output stream out.
Definition TAxis.cxx:706
TClass * IsA() const override
Definition TAxis.h:179
Int_t GetLast() const
Return last bin on the axis i.e.
Definition TAxis.cxx:464
virtual void ImportAttributes(const TAxis *axis)
Copy axis attributes to this.
Definition TAxis.cxx:676
virtual const char * GetTimeFormatOnly() const
Return only the time format from the string fTimeFormat.
Definition TAxis.cxx:595
virtual Double_t GetBinCenterLog(Int_t bin) const
Return center of bin in log With a log-equidistant binning for a bin with low and up edges,...
Definition TAxis.cxx:496
void SetAlphanumeric(Bool_t alphanumeric=kTRUE)
Set axis alphanumeric.
Definition TAxis.cxx:838
void Streamer(TBuffer &) override
Stream an object of class TAxis.
Definition TAxis.cxx:1215
TAxis & operator=(const TAxis &)
Assignment operator.
Definition TAxis.cxx:113
~TAxis() override
Destructor.
Definition TAxis.cxx:84
void ChangeLabelByValue(Double_t labValue, Double_t labAngle=-1., Double_t labSize=-1., Int_t labAlign=-1, Int_t labColor=-1, Int_t labFont=-1, const TString &labText="")
Define new text attributes for the label value "labValue".
Definition TAxis.cxx:1005
virtual void SetRangeUser(Double_t ufirst, Double_t ulast)
Set the viewing range for the axis from ufirst to ulast (in user coordinates, that is,...
Definition TAxis.cxx:1081
virtual const char * GetTimeFormat() const
Definition TAxis.h:134
virtual void GetLowEdge(Double_t *edge) const
Return an array with the low edge of all bins.
Definition TAxis.cxx:558
virtual void SetTimeFormat(const char *format="")
Change the format used for time plotting.
Definition TAxis.cxx:1156
Bool_t CanBeAlphanumeric()
Definition TAxis.h:89
TString fTimeFormat
Date&time format, ex: 09/12/99 12:34:00.
Definition TAxis.h:43
virtual TObject * GetParent() const
Definition TAxis.h:130
virtual void SetRange(Int_t first=0, Int_t last=0)
Set the viewing range for the axis using bin numbers.
Definition TAxis.cxx:1052
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
Definition TAxis.cxx:537
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition TAxis.cxx:523
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition TAxis.cxx:453
virtual const char * GetTicks() const
Return the ticks option (see SetTicks)
Definition TAxis.cxx:630
UShort_t fBits2
Second bit status word.
Definition TAxis.h:41
Int_t fFirst
First bin to display.
Definition TAxis.h:39
Buffer base class used for serializing objects.
Definition TBuffer.h:43
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t ReadArray(Bool_t *&b)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
Bool_t IsReading() const
Definition TBuffer.h:86
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual Int_t GetEntries() const
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition TDatime.h:37
UInt_t Convert(Bool_t toGMT=kFALSE) const
Convert fDatime from TDatime format to the standard time_t format.
Definition TDatime.cxx:182
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
virtual void GetStats(Double_t *stats) const
fill the array stats from the contents of this histogram The array stats must be correctly dimensione...
Definition TH1.cxx:7866
static TClass * Class()
virtual Int_t GetDimension() const
Definition TH1.h:284
@ kIsZoomed
Bit set when zooming on Y axis.
Definition TH1.h:169
TAxis * GetXaxis()
Definition TH1.h:325
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Return maximum value smaller than maxval of bins in the range, unless the value has been overridden b...
Definition TH1.cxx:8578
virtual void SetMaximum(Double_t maximum=-1111)
Definition TH1.h:405
TAxis * GetYaxis()
Definition TH1.h:326
virtual void SetMinimum(Double_t minimum=-1111)
Definition TH1.h:406
@ kNstat
Size of statistics data (up to TProfile3D)
Definition TH1.h:184
virtual Double_t GetMinimum(Double_t minval=-FLT_MAX) const
Return minimum value larger than minval of bins in the range, unless the value has been overridden by...
Definition TH1.cxx:8668
static void Optimize(Double_t A1, Double_t A2, Int_t nold, Double_t &BinLow, Double_t &BinHigh, Int_t &nbins, Double_t &BWID, Option_t *option="")
Static function to compute reasonable axis limits.
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition THashList.h:34
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
void Rehash(Int_t newCapacity)
Rehash the hashlist.
TObject * FindObject(const char *name) const override
Find object using its name.
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
Definition TList.h:81
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:468
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
void Copy(TObject &named) const override
Copy this to obj.
Definition TNamed.cxx:94
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:164
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
void Streamer(TBuffer &) override
Stream an object of class TObject.
Collectable string class.
Definition TObjString.h:28
void SetString(const char *s)
Definition TObjString.h:45
const char * GetName() const override
Returns name of object.
Definition TObjString.h:38
Mother of all ROOT objects.
Definition TObject.h:41
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:199
virtual UInt_t GetUniqueID() const
Return the unique object id.
Definition TObject.cxx:474
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:991
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:798
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:542
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1005
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Definition TObject.cxx:809
void ResetBit(UInt_t f)
Definition TObject.h:198
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:979
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
void ToLower()
Change string to lower-case.
Definition TString.cxx:1182
const char * Data() const
Definition TString.h:376
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:704
Bool_t IsNull() const
Definition TString.h:414
TString & Remove(Ssiz_t pos)
Definition TString.h:685
virtual void Streamer(TBuffer &)
Stream a string object.
Definition TString.cxx:1412
TString & Append(const char *cs)
Definition TString.h:572
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:651
Double_t GetTimeOffset() const
Definition TStyle.h:269
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:250
Double_t Floor(Double_t x)
Rounds x downward, returning the largest integral value that is not greater than x.
Definition TMath.h:684
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:666
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Binary search in an array of n values to locate value.
Definition TMathBase.h:347
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123