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