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