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