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