Logo ROOT  
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
37This class manages histogram axis. It is referenced by TH1 and TGraph.
38To make a graphical representation of an histogram axis, this class
39references the TGaxis class. TAxis supports axis with fixed or variable bin sizes.
40Labels may be associated to individual bins.
41See 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
75TAxis::TAxis(Int_t nbins,const Double_t *xbins): TNamed(), TAttAxis()
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) {
95 delete fModLabs;
96 fModLabs = 0;
97 }
98}
99
100////////////////////////////////////////////////////////////////////////////////
101/// Copy constructor.
102
103TAxis::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
124const 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
208void 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);
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
324Int_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
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
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 does not exist just return -1 .
385/// Do not attempt to modify the axis. This is different than FindBin
386
387Int_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
426const 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
539void 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 low edge of all bins
547
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
557const 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
572const 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 can be:
591/// - "a" sort by alphabetic order
592/// - ">" sort by decreasing values
593/// - "<" sort by increasing values
594/// - "h" draw labels horizontal
595/// - "v" draw labels vertical
596/// - "u" draw labels up (end of label right adjusted)
597/// - "d" draw labels down (start of label left adjusted)
598
600{
601 if (!fLabels) {
602 Warning("Sort","Cannot sort. No labels");
603 return;
604 }
605 TH1 *h = (TH1*)GetParent();
606 if (!h) {
607 Error("Sort","Axis has no parent");
608 return;
609 }
610
611 h->LabelsOption(option,GetName());
612}
613
614////////////////////////////////////////////////////////////////////////////////
615/// Copy axis attributes to this
616
618{
619 SetTitle(axis->GetTitle());
621 SetAxisColor(axis->GetAxisColor());
623 SetLabelFont(axis->GetLabelFont());
625 SetLabelSize(axis->GetLabelSize());
628 SetTitleSize(axis->GetTitleSize());
630 SetTitleFont(axis->GetTitleFont());
640}
641
642
643
644////////////////////////////////////////////////////////////////////////////////
645/// Save axis attributes as C++ statement(s) on output stream out
646
647void TAxis::SaveAttributes(std::ostream &out, const char *name, const char *subname)
648{
649 char quote = '"';
650 if (strlen(GetTitle())) {
651 TString t(GetTitle());
652 t.ReplaceAll("\\","\\\\");
653 out<<" "<<name<<subname<<"->SetTitle("<<quote<<t.Data()<<quote<<");"<<std::endl;
654 }
655 if (fTimeDisplay) {
656 out<<" "<<name<<subname<<"->SetTimeDisplay(1);"<<std::endl;
657 out<<" "<<name<<subname<<"->SetTimeFormat("<<quote<<GetTimeFormat()<<quote<<");"<<std::endl;
658 }
659 if (fLabels) {
660 TIter next(fLabels);
661 TObjString *obj;
662 while ((obj=(TObjString*)next())) {
663 out<<" "<<name<<subname<<"->SetBinLabel("<<obj->GetUniqueID()<<","<<quote<<obj->GetName()<<quote<<");"<<std::endl;
664 }
665 }
666
667 if (fFirst || fLast) {
668 out<<" "<<name<<subname<<"->SetRange("<<fFirst<<","<<fLast<<");"<<std::endl;
669 }
670
671 if (TestBit(kLabelsHori)) {
672 out<<" "<<name<<subname<<"->SetBit(TAxis::kLabelsHori);"<<std::endl;
673 }
674
675 if (TestBit(kLabelsVert)) {
676 out<<" "<<name<<subname<<"->SetBit(TAxis::kLabelsVert);"<<std::endl;
677 }
678
679 if (TestBit(kLabelsDown)) {
680 out<<" "<<name<<subname<<"->SetBit(TAxis::kLabelsDown);"<<std::endl;
681 }
682
683 if (TestBit(kLabelsUp)) {
684 out<<" "<<name<<subname<<"->SetBit(TAxis::kLabelsUp);"<<std::endl;
685 }
686
687 if (TestBit(kCenterLabels)) {
688 out<<" "<<name<<subname<<"->CenterLabels(true);"<<std::endl;
689 }
690
691 if (TestBit(kCenterTitle)) {
692 out<<" "<<name<<subname<<"->CenterTitle(true);"<<std::endl;
693 }
694
695 if (TestBit(kRotateTitle)) {
696 out<<" "<<name<<subname<<"->RotateTitle(true);"<<std::endl;
697 }
698
699 if (TestBit(kDecimals)) {
700 out<<" "<<name<<subname<<"->SetDecimals();"<<std::endl;
701 }
702
703 if (TestBit(kMoreLogLabels)) {
704 out<<" "<<name<<subname<<"->SetMoreLogLabels();"<<std::endl;
705 }
706
707 if (TestBit(kNoExponent)) {
708 out<<" "<<name<<subname<<"->SetNoExponent();"<<std::endl;
709 }
710
711 TAttAxis::SaveAttributes(out,name,subname);
712}
713
714////////////////////////////////////////////////////////////////////////////////
715/// Initialize axis with fix bins
716
717void TAxis::Set(Int_t nbins, Double_t xlow, Double_t xup)
718{
719 fNbins = nbins;
720 fXmin = xlow;
721 fXmax = xup;
722 if (!fParent) SetDefaults();
723 if (fXbins.fN > 0) fXbins.Set(0);
724}
725
726////////////////////////////////////////////////////////////////////////////////
727/// Initialize axis with variable bins
728
729void TAxis::Set(Int_t nbins, const Float_t *xbins)
730{
731 Int_t bin;
732 fNbins = nbins;
733 fXbins.Set(fNbins+1);
734 for (bin=0; bin<= fNbins; bin++)
735 fXbins.fArray[bin] = xbins[bin];
736 for (bin=1; bin<= fNbins; bin++)
737 if (fXbins.fArray[bin] < fXbins.fArray[bin-1])
738 Error("TAxis::Set", "bins must be in increasing order");
739 fXmin = fXbins.fArray[0];
741 if (!fParent) SetDefaults();
742}
743
744////////////////////////////////////////////////////////////////////////////////
745/// Initialize axis with variable bins
746
747void TAxis::Set(Int_t nbins, const Double_t *xbins)
748{
749 Int_t bin;
750 fNbins = nbins;
751 fXbins.Set(fNbins+1);
752 for (bin=0; bin<= fNbins; bin++)
753 fXbins.fArray[bin] = xbins[bin];
754 for (bin=1; bin<= fNbins; bin++)
755 if (fXbins.fArray[bin] < fXbins.fArray[bin-1])
756 Error("TAxis::Set", "bins must be in increasing order");
757 fXmin = fXbins.fArray[0];
759 if (!fParent) SetDefaults();
760}
761
762////////////////////////////////////////////////////////////////////////////////
763/// Set axis alphanumeric
764
766{
767 if (alphanumeric) fBits2 |= kAlphanumeric;
768 else fBits2 &= ~kAlphanumeric;
769
770 // clear underflow and overflow (in an alphanumeric situation they do not make sense)
771 // NOTE: using AddBinContent instead of SetBinContent in order to not change
772 // the number of entries
773 //((TH1 *)fParent)->ClearUnderflowAndOverflow();
774 // L.M. 26.1.15 Keep underflow and overflows (see ROOT-7034)
775 if (gDebug && fParent) {
776 TH1 * h = dynamic_cast<TH1*>( fParent);
777 if (!h) return;
778 double s[TH1::kNstat];
779 h->GetStats(s);
780 if (s[0] != 0. && gDebug > 0)
781 Info("SetAlphanumeric","Histogram %s is set alphanumeric but has non-zero content",GetName());
782 }
783}
784
785
786////////////////////////////////////////////////////////////////////////////////
787/// Set axis default values (from TStyle)
788
790{
791 fFirst = 0;
792 fLast = 0;
793 fBits2 = 0;
794 char name[2];
795 strlcpy(name,GetName(),2);
796 name[1] = 0;
798 fTimeDisplay = 0;
800}
801
802////////////////////////////////////////////////////////////////////////////////
803/// Set label for bin.
804/// If no label list exists, it is created. If all the bins have labels, the
805/// axis becomes alphanumeric and extendable.
806/// New labels will not be added with the Fill method but will end-up in the
807/// underflow bin. See documentation of TAxis::FindBin(const char*)
808
809void TAxis::SetBinLabel(Int_t bin, const char *label)
810{
811 if (!fLabels) fLabels = new THashList(fNbins,3);
812
813 if (bin <= 0 || bin > fNbins) {
814 Error("SetBinLabel","Illegal bin number: %d",bin);
815 return;
816 }
817
818 // Check whether this bin already has a label.
819 TIter next(fLabels);
820 TObjString *obj;
821 while ((obj=(TObjString*)next())) {
822 if ( obj->GetUniqueID()==(UInt_t)bin ) {
823 // It does. Overwrite it.
824 obj->SetString(label);
825 // LM need to rehash the labels list (see ROOT-5025)
827 return;
828 }
829 }
830 // It doesn't. Add this new label.
831 obj = new TObjString(label);
832 fLabels->Add(obj);
833 obj->SetUniqueID((UInt_t)bin);
834
835 // check for Alphanumeric case (labels for each bin)
836 if (CanBeAlphanumeric() && fLabels->GetSize() == fNbins) {
839 }
840}
841
842////////////////////////////////////////////////////////////////////////////////
843/// Define new text attributes for the label number "labNum". It allows to do a
844/// fine tuning of the labels. All the attributes can be changed, even the
845/// label text itself.
846///
847/// \param[in] labNum Number of the label to be changed, negative numbers start from the end
848/// \param[in] labAngle New angle value
849/// \param[in] labSize New size (0 erase the label)
850/// \param[in] labAlign New alignment value
851/// \param[in] labColor New label color
852/// \param[in] labFont New label font
853/// \param[in] labText New label text
854///
855/// If an attribute should not be changed just give the value "-1".
856///
857/// If labnum=0 the list of modified labels is reset.
858
859void TAxis::ChangeLabel(Int_t labNum, Double_t labAngle, Double_t labSize,
860 Int_t labAlign, Int_t labColor, Int_t labFont,
861 TString labText)
862{
863 if (!fModLabs) fModLabs = new TList();
864
865 // Reset the list of modified labels.
866 if (labNum == 0) {
867 delete fModLabs;
868 fModLabs = 0;
869 return;
870 }
871
872 TAxisModLab *ml = new TAxisModLab();
873 ml->SetLabNum(labNum);
874 ml->SetAngle(labAngle);
875 ml->SetSize(labSize);
876 ml->SetAlign(labAlign);
877 ml->SetColor(labColor);
878 ml->SetFont(labFont);
879 ml->SetText(labText);
880
881 fModLabs->Add((TObject*)ml);
882}
883
884
885////////////////////////////////////////////////////////////////////////////////
886/// Set the viewing range for the axis from bin first to last.
887/// To set a range using the axis coordinates, use TAxis::SetRangeUser.
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
904{
905
906 Int_t nCells = fNbins + 1; // bins + overflow
907
908 // special reset range cases
909 if (last < first || (first < 0 && last < 0) ||
910 (first > nCells && last > nCells) || (first == 0 && last == 0)
911 ) {
912 fFirst = 1;
913 fLast = fNbins;
914 SetBit(kAxisRange, 0);
915 } else {
916 fFirst = std::max(first, 0);
917 fLast = std::min(last, nCells);
918 SetBit(kAxisRange, 1);
919 }
920
921}
922
923
924////////////////////////////////////////////////////////////////////////////////
925/// Set the viewing range for the axis from ufirst to ulast (in user coordinates).
926/// To set a range using the axis bin numbers, use TAxis::SetRange.
927
929{
930 if (!strstr(GetName(),"xaxis")) {
931 TH1 *hobj = (TH1*)GetParent();
932 if (hobj &&
933 ((hobj->GetDimension() == 2 && strstr(GetName(),"zaxis"))
934 || (hobj->GetDimension() == 1 && strstr(GetName(),"yaxis")))) {
935 hobj->SetMinimum(ufirst);
936 hobj->SetMaximum(ulast);
937 return;
938 }
939 }
940 Int_t ifirst = FindFixBin(ufirst);
941 Int_t ilast = FindFixBin(ulast);
942 // fixes for numerical error and for https://savannah.cern.ch/bugs/index.php?99777
943 if (GetBinUpEdge(ifirst) <= ufirst ) ifirst += 1;
944 if (GetBinLowEdge(ilast) >= ulast ) ilast -= 1;
945 SetRange(ifirst, ilast);
946}
947
948////////////////////////////////////////////////////////////////////////////////
949/// Set ticks orientation.
950/// option = "+" ticks drawn on the "positive side" (default)
951/// option = "-" ticks drawn on the "negative side"
952/// option = "+-" ticks drawn on both sides
953
955{
958 if (strchr(option,'+')) SetBit(kTickPlus);
959 if (strchr(option,'-')) SetBit(kTickMinus);
960}
961
962////////////////////////////////////////////////////////////////////////////////
963/// Change the format used for time plotting
964///
965/// The format string for date and time use the same options as the one used
966/// in the standard strftime C function, i.e. :
967/// for date :
968///
969/// %a abbreviated weekday name
970/// %b abbreviated month name
971/// %d day of the month (01-31)
972/// %m month (01-12)
973/// %y year without century
974///
975/// for time :
976///
977/// %H hour (24-hour clock)
978/// %I hour (12-hour clock)
979/// %p local equivalent of AM or PM
980/// %M minute (00-59)
981/// %S seconds (00-61)
982/// %% %
983///
984/// This function allows also to define the time offset. It is done via %F
985/// which should be appended at the end of the format string. The time
986/// offset has the following format: 'yyyy-mm-dd hh:mm:ss'
987/// Example:
988///
989/// h = new TH1F("Test","h",3000,0.,200000.);
990/// h->GetXaxis()->SetTimeDisplay(1);
991/// h->GetXaxis()->SetTimeFormat("%d\/%m\/%y%F2000-02-28 13:00:01");
992///
993/// This defines the time format being "dd/mm/yy" and the time offset as the
994/// February 28th 2003 at 13:00:01
995///
996/// If %F is not specified, the time offset used will be the one defined by:
997/// gStyle->SetTimeOffset. For example like that:
998///
999/// TDatime da(2003,02,28,12,00,00);
1000/// gStyle->SetTimeOffset(da.Convert());
1001
1002void TAxis::SetTimeFormat(const char *tformat)
1003{
1004 TString timeformat = tformat;
1005
1006 if (timeformat.Index("%F")>=0 || timeformat.IsNull()) {
1007 fTimeFormat = timeformat;
1008 return;
1009 }
1010
1011 Int_t idF = fTimeFormat.Index("%F");
1012 if (idF>=0) {
1013 Int_t lnF = fTimeFormat.Length();
1014 TString stringtimeoffset = fTimeFormat(idF,lnF);
1015 fTimeFormat = tformat;
1016 fTimeFormat.Append(stringtimeoffset);
1017 } else {
1018 fTimeFormat = tformat;
1020 }
1021}
1022
1023
1024////////////////////////////////////////////////////////////////////////////////
1025/// Change the time offset
1026/// If option = "gmt", set display mode to GMT.
1027
1029{
1030 TString opt = option;
1031 opt.ToLower();
1032
1033 char tmp[20];
1034 time_t timeoff;
1035 struct tm* utctis;
1036 Int_t idF = fTimeFormat.Index("%F");
1037 if (idF>=0) fTimeFormat.Remove(idF);
1038 fTimeFormat.Append("%F");
1039
1040 timeoff = (time_t)((Long_t)(toffset));
1041 // offset is always saved in GMT to allow file transport
1042 // to different time zones
1043 utctis = gmtime(&timeoff);
1044
1045 strftime(tmp,20,"%Y-%m-%d %H:%M:%S",utctis);
1046 fTimeFormat.Append(tmp);
1047
1048 // append the decimal part of the time offset
1049 Double_t ds = toffset-(Int_t)toffset;
1050 snprintf(tmp,20,"s%g",ds);
1051 fTimeFormat.Append(tmp);
1052
1053 // add GMT/local option
1054 if (opt.Contains("gmt")) fTimeFormat.Append(" GMT");
1055}
1056
1057
1058////////////////////////////////////////////////////////////////////////////////
1059/// Stream an object of class TAxis.
1060
1061void TAxis::Streamer(TBuffer &R__b)
1062{
1063 if (R__b.IsReading()) {
1064 UInt_t R__s, R__c;
1065 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1066 if (R__v > 5) {
1067 R__b.ReadClassBuffer(TAxis::Class(), this, R__v, R__s, R__c);
1068 return;
1069 }
1070 //====process old versions before automatic schema evolution
1071 TNamed::Streamer(R__b);
1072 TAttAxis::Streamer(R__b);
1073 R__b >> fNbins;
1074 if (R__v < 5) {
1076 R__b >> xmin; fXmin = xmin;
1077 R__b >> xmax; fXmax = xmax;
1078 Float_t *xbins = 0;
1079 Int_t n = R__b.ReadArray(xbins);
1080 fXbins.Set(n);
1081 for (Int_t i=0;i<n;i++) fXbins.fArray[i] = xbins[i];
1082 delete [] xbins;
1083 } else {
1084 R__b >> fXmin;
1085 R__b >> fXmax;
1086 fXbins.Streamer(R__b);
1087 }
1088 if (R__v > 2) {
1089 R__b >> fFirst;
1090 R__b >> fLast;
1091 // following lines required to repair for a bug in Root version 1.03
1092 if (fFirst < 0 || fFirst > fNbins) fFirst = 0;
1093 if (fLast < 0 || fLast > fNbins) fLast = 0;
1094 if (fLast < fFirst) { fFirst = 0; fLast = 0;}
1095 if (fFirst ==0 && fLast == 0) SetBit(kAxisRange,0);
1096 }
1097 if (R__v > 3) {
1098 R__b >> fTimeDisplay;
1099 fTimeFormat.Streamer(R__b);
1100 } else {
1101 SetTimeFormat();
1102 }
1103 R__b.CheckByteCount(R__s, R__c, TAxis::IsA());
1104 //====end of old versions
1105
1106 } else {
1107 R__b.WriteClassBuffer(TAxis::Class(),this);
1108 }
1109}
1110
1111////////////////////////////////////////////////////////////////////////////////
1112/// Reset first & last bin to the full range
1113
1115{
1116 if (!gPad) return;
1117 gPad->SetView();
1118
1119 //unzoom object owning this axis
1120 SetRange(0,0);
1121 TH1 *hobj1 = (TH1*)GetParent();
1122 if (!strstr(GetName(),"xaxis")) {
1123 if (!hobj1) return;
1124 if (hobj1->GetDimension() == 2) {
1125 if (strstr(GetName(),"zaxis")) {
1126 hobj1->SetMinimum();
1127 hobj1->SetMaximum();
1128 hobj1->ResetBit(TH1::kIsZoomed);
1129 }
1130 return;
1131 }
1132 if (strcmp(hobj1->GetName(),"hframe") == 0 ) {
1133 hobj1->SetMinimum(fXmin);
1134 hobj1->SetMaximum(fXmax);
1135 } else {
1136 if (fXmin==hobj1->GetMinimum() && fXmax==hobj1->GetMaximum()) {
1137 hobj1->SetMinimum(fXmin);
1138 hobj1->SetMaximum(fXmax);
1139 } else {
1140 hobj1->SetMinimum();
1141 hobj1->SetMaximum();
1142 }
1143 hobj1->ResetBit(TH1::kIsZoomed);
1144 }
1145 }
1146 //must unzoom all histograms in the pad
1147 TIter next(gPad->GetListOfPrimitives());
1148 TObject *obj;
1149 while ((obj= next())) {
1150 if (!obj->InheritsFrom(TH1::Class())) continue;
1151 TH1 *hobj = (TH1*)obj;
1152 if (hobj == hobj1) continue;
1153 if (!strstr(GetName(),"xaxis")) {
1154 if (hobj->GetDimension() == 2) {
1155 if (strstr(GetName(),"zaxis")) {
1156 hobj->SetMinimum();
1157 hobj->SetMaximum();
1158 hobj->ResetBit(TH1::kIsZoomed);
1159 } else {
1160 hobj->GetYaxis()->SetRange(0,0);
1161 }
1162 return;
1163 }
1164 if (strcmp(hobj->GetName(),"hframe") == 0 ) {
1165 hobj->SetMinimum(fXmin);
1166 hobj->SetMaximum(fXmax);
1167 } else {
1168 hobj->SetMinimum();
1169 hobj->SetMaximum();
1170 hobj->ResetBit(TH1::kIsZoomed);
1171 }
1172 } else {
1173 hobj->GetXaxis()->SetRange(0,0);
1174 }
1175 }
1176
1177 gPad->UnZoomed();
1178}
1179
1180////////////////////////////////////////////////////////////////////////////////
1181/// Zoom out by a factor of 'factor' (default =2)
1182/// uses previous zoom factor by default
1183/// Keep center defined by 'offset' fixed
1184/// ie. -1 at left of current range, 0 in center, +1 at right
1185
1187{
1188
1189 if (factor <= 0) factor = 2;
1190 Double_t center = (GetFirst()*(1-offset) + GetLast()*(1+offset))/2.;
1191 Int_t first = int(TMath::Floor(center+(GetFirst()-center)*factor + 0.4999999));
1192 Int_t last = int(TMath::Floor(center+(GetLast() -center)*factor + 0.5000001));
1193 if (first==GetFirst() && last==GetLast()) { first--; last++; }
1194 SetRange(first,last);
1195}
void Class()
Definition: Class.C:29
#define h(i)
Definition: RSha256.hxx:106
int Int_t
Definition: RtypesCore.h:41
short Version_t
Definition: RtypesCore.h:61
unsigned int UInt_t
Definition: RtypesCore.h:42
long Long_t
Definition: RtypesCore.h:50
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:365
R__EXTERN Int_t gDebug
Definition: Rtypes.h:91
char name[80]
Definition: TGX11.cxx:109
float xmin
Definition: THbookFile.cxx:93
float xmax
Definition: THbookFile.cxx:93
R__EXTERN TStyle * gStyle
Definition: TStyle.h:407
#define gPad
Definition: TVirtualPad.h:286
#define snprintf
Definition: civetweb.c:1540
Double_t * fArray
Definition: TArrayD.h:30
void Copy(TArrayD &array) const
Definition: TArrayD.h:42
void Set(Int_t n)
Set size of this array to n doubles.
Definition: TArrayD.cxx:106
Int_t fN
Definition: TArray.h:38
Manages histogram axis attributes.
Definition: TAttAxis.h:18
virtual Color_t GetTitleColor() const
Definition: TAttAxis.h:46
virtual Color_t GetLabelColor() const
Definition: TAttAxis.h:38
virtual Int_t GetNdivisions() const
Definition: TAttAxis.h:36
virtual Color_t GetAxisColor() const
Definition: TAttAxis.h:37
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title.
Definition: TAttAxis.cxx:294
virtual Style_t GetTitleFont() const
Definition: TAttAxis.h:47
virtual Float_t GetLabelOffset() const
Definition: TAttAxis.h:40
virtual void SetAxisColor(Color_t color=1, Float_t alpha=1.)
Set color of the line axis and tick marks.
Definition: TAttAxis.cxx:163
virtual void SetLabelSize(Float_t size=0.04)
Set size of axis labels.
Definition: TAttAxis.cxx:204
virtual Style_t GetLabelFont() const
Definition: TAttAxis.h:39
virtual void SetTitleFont(Style_t font=62)
Set the title font.
Definition: TAttAxis.cxx:322
virtual void SetLabelOffset(Float_t offset=0.005)
Set distance between the axis and the labels.
Definition: TAttAxis.cxx:193
virtual void SetLabelFont(Style_t font=62)
Set labels' font.
Definition: TAttAxis.cxx:183
virtual void SetTitleSize(Float_t size=0.04)
Set size of axis title.
Definition: TAttAxis.cxx:304
virtual void SaveAttributes(std::ostream &out, const char *name, const char *subname)
Save axis attributes as C++ statement(s) on output stream out.
Definition: TAttAxis.cxx:111
virtual void SetTitleColor(Color_t color=1)
Set color of axis title.
Definition: TAttAxis.cxx:313
virtual Float_t GetTitleSize() const
Definition: TAttAxis.h:44
virtual Float_t GetLabelSize() const
Definition: TAttAxis.h:41
virtual Float_t GetTickLength() const
Definition: TAttAxis.h:45
virtual void ResetAttAxis(Option_t *option="")
Reset axis attributes.
Definition: TAttAxis.cxx:79
virtual Float_t GetTitleOffset() const
Definition: TAttAxis.h:43
virtual void SetTickLength(Float_t length=0.03)
Set tick mark length.
Definition: TAttAxis.cxx:280
virtual void SetNdivisions(Int_t n=510, Bool_t optim=kTRUE)
Set the number of divisions for this axis.
Definition: TAttAxis.cxx:229
void Copy(TAttAxis &attaxis) const
Copy of the object.
Definition: TAttAxis.cxx:61
virtual void SetLabelColor(Color_t color=1, Float_t alpha=1.)
Set color of labels.
Definition: TAttAxis.cxx:173
TAxis helper class used to store the modified labels.
Definition: TAxisModLab.h:21
void SetColor(Int_t c=-1)
Set modified label color.
Definition: TAxisModLab.cxx:70
void SetSize(Double_t s=-1.)
Set modified label size.
Definition: TAxisModLab.cxx:56
void SetFont(Int_t f=-1)
Set modified label font.
Definition: TAxisModLab.cxx:77
void SetText(TString t="")
Set modified label text.
Definition: TAxisModLab.cxx:84
void SetAlign(Int_t a=-1)
Set modified label alignment.
Definition: TAxisModLab.cxx:63
void SetLabNum(Int_t n=0)
Set modified label number.
Definition: TAxisModLab.cxx:42
void SetAngle(Double_t a=-1.)
Set modified label angle.
Definition: TAxisModLab.cxx:49
Class to manage histogram axis.
Definition: TAxis.h:30
virtual void GetCenter(Double_t *center) const
Return an array with the center of all bins.
Definition: TAxis.cxx:539
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:1028
virtual void LabelsOption(Option_t *option="h")
Set option(s) to draw axis with labels option can be:
Definition: TAxis.cxx:599
virtual void SetDefaults()
Set axis default values (from TStyle)
Definition: TAxis.cxx:789
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
Definition: TAxis.cxx:809
Int_t fLast
Definition: TAxis.h:38
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:1186
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
Definition: TAxis.cxx:464
TObject * fParent
Definition: TAxis.h:42
Double_t fXmax
Definition: TAxis.h:35
Bool_t CanExtend() const
Definition: TAxis.h:82
TArrayD fXbins
Definition: TAxis.h:36
TAxis()
Default constructor.
Definition: TAxis.cxx:47
virtual void UnZoom()
Reset first & last bin to the full range.
Definition: TAxis.cxx:1114
THashList * fLabels
Object owning this axis.
Definition: TAxis.h:43
void SetCanExtend(Bool_t canExtend)
Definition: TAxis.h:86
virtual void SetTicks(Option_t *option="+")
Set ticks orientation.
Definition: TAxis.cxx:954
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:647
@ kTickMinus
Definition: TAxis.h:60
@ kLabelsUp
Definition: TAxis.h:70
@ kCenterTitle
Definition: TAxis.h:62
@ kRotateTitle
Definition: TAxis.h:64
@ kNoExponent
Definition: TAxis.h:66
@ kMoreLogLabels
Definition: TAxis.h:72
@ kTickPlus
Definition: TAxis.h:59
@ kLabelsDown
Definition: TAxis.h:69
@ kLabelsHori
Definition: TAxis.h:67
@ kAxisRange
Definition: TAxis.h:61
@ kDecimals
Definition: TAxis.h:58
@ kCenterLabels
Definition: TAxis.h:63
@ kLabelsVert
Definition: TAxis.h:68
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TAxis.cxx:267
Bool_t fTimeDisplay
Definition: TAxis.h:40
TList * fModLabs
Definition: TAxis.h:44
const char * GetBinLabel(Int_t bin) const
Return label for bin.
Definition: TAxis.cxx:426
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
Definition: TAxis.cxx:279
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
Definition: TAxis.cxx:504
Int_t fNbins
Definition: TAxis.h:33
Double_t fXmin
Definition: TAxis.h:34
virtual void Set(Int_t nbins, Double_t xmin, Double_t xmax)
Initialize axis with fix bins.
Definition: TAxis.cxx:717
Bool_t HasBinWithoutLabel() const
this helper function checks if there is a bin without a label if all bins have labels,...
Definition: TAxis.cxx:583
virtual Int_t FindFixBin(Double_t x) const
Find bin number corresponding to abscissa x.
Definition: TAxis.cxx:405
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 void Copy(TObject &axis) const
Copy axis structure to another axis.
Definition: TAxis.cxx:208
Int_t GetLast() const
Return last bin on the axis i.e.
Definition: TAxis.cxx:455
Bool_t IsAlphanumeric()
Definition: TAxis.h:84
virtual void ImportAttributes(const TAxis *axis)
Copy axis attributes to this.
Definition: TAxis.cxx:617
virtual const char * GetTimeFormatOnly() const
Return only the time format from the string fTimeFormat.
Definition: TAxis.cxx:557
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
void SetAlphanumeric(Bool_t alphanumeric=kTRUE)
Set axis alphanumeric.
Definition: TAxis.cxx:765
@ kAlphanumeric
Definition: TAxis.h:48
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to an axis.
Definition: TAxis.cxx:251
TAxis & operator=(const TAxis &)
Assignment operator.
Definition: TAxis.cxx:111
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:928
virtual const char * GetTimeFormat() const
Definition: TAxis.h:127
virtual void GetLowEdge(Double_t *edge) const
Return an array with the low edge of all bins.
Definition: TAxis.cxx:548
const char * GetTitle() const
Returns title of object.
Definition: TAxis.h:129
virtual void SetTimeFormat(const char *format="")
Change the format used for time plotting.
Definition: TAxis.cxx:1002
virtual ~TAxis()
Destructor.
Definition: TAxis.cxx:86
Bool_t CanBeAlphanumeric()
Definition: TAxis.h:83
TString fTimeFormat
Definition: TAxis.h:41
virtual TObject * GetParent() const
Definition: TAxis.h:123
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:903
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
Definition: TAxis.cxx:526
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition: TAxis.cxx:514
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition: TAxis.cxx:444
virtual const char * GetTicks() const
Return the ticks option (see SetTicks)
Definition: TAxis.cxx:572
UShort_t fBits2
Definition: TAxis.h:39
Int_t fFirst
Definition: TAxis.h:37
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:859
Buffer base class used for serializing objects.
Definition: TBuffer.h:42
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual Int_t ReadArray(Bool_t *&b)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
Bool_t IsReading() const
Definition: TBuffer.h:85
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual Int_t GetEntries() const
Definition: TCollection.h:177
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
The TH1 histogram class.
Definition: TH1.h:56
virtual Int_t GetDimension() const
Definition: TH1.h:278
@ kIsZoomed
bit set when zooming on Y axis
Definition: TH1.h:164
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
Definition: TH1.h:316
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:7994
virtual void SetMaximum(Double_t maximum=-1111)
Definition: TH1.h:394
TAxis * GetYaxis()
Definition: TH1.h:317
virtual void SetMinimum(Double_t minimum=-1111)
Definition: TH1.h:395
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:8079
@ kNstat
Definition: TH1.h:179
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:34
TObject * FindObject(const char *name) const
Find object using its name.
Definition: THashList.cxx:262
void Rehash(Int_t newCapacity)
Rehash the hashlist.
Definition: THashList.cxx:368
void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: THashList.cxx:207
A doubly linked list.
Definition: TList.h:44
virtual void Add(TObject *obj)
Definition: TList.h:87
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:467
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual void Copy(TObject &named) const
Copy this to obj.
Definition: TNamed.cxx:94
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Collectable string class.
Definition: TObjString.h:28
const char * GetName() const
Returns name of object.
Definition: TObjString.h:38
void SetString(const char *s)
Definition: TObjString.h:45
Mother of all ROOT objects.
Definition: TObject.h:37
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
virtual UInt_t GetUniqueID() const
Return the unique object id.
Definition: TObject.cxx:375
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:866
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:443
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Definition: TObject.cxx:705
void ResetBit(UInt_t f)
Definition: TObject.h:171
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:854
Basic string class.
Definition: TString.h:131
Ssiz_t Length() const
Definition: TString.h:405
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1125
const char * Data() const
Definition: TString.h:364
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:687
Bool_t IsNull() const
Definition: TString.h:402
TString & Remove(Ssiz_t pos)
Definition: TString.h:668
TString & Append(const char *cs)
Definition: TString.h:559
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:619
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:634
Double_t GetTimeOffset() const
Definition: TStyle.h:257
Double_t x[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16
for(Int_t i=0;i< n;i++)
Definition: legend1.C:18
static constexpr double s
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
Double_t Floor(Double_t x)
Definition: TMath.h:693
Double_t Sqrt(Double_t x)
Definition: TMath.h:681
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Definition: TMathBase.h:278
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
Definition: first.py:1