2727#include " snprintf.h"
2828
2929#include < iostream>
30+ #include < cmath>
3031#include < ctime>
3132#include < cassert>
3233
@@ -779,10 +780,17 @@ void TAxis::SaveAttributes(std::ostream &out, const char *name, const char *subn
779780
780781// //////////////////////////////////////////////////////////////////////////////
781782// / Initialize axis with fix bins
783+ // /
784+ // / An error is printed if xup <= xlow
785+ // / or in any of them is infinite (due to resulting undefined fixed bin width)
782786
783787void TAxis::Set (Int_t nbins, Double_t xlow, Double_t xup)
784788{
785789 fNbins = nbins;
790+ if (xup <= xlow)
791+ Error (" TAxis::Set" , " upper edge must be strictly higher than lower edge" );
792+ if (std::isinf (xlow) || std::isinf (xup))
793+ Error (" TAxis::Set" , " fixed binwidth not compatible with infinite lower/upper edges" );
786794 fXmin = xlow;
787795 fXmax = xup;
788796 if (!fParent ) SetDefaults ();
@@ -791,6 +799,8 @@ void TAxis::Set(Int_t nbins, Double_t xlow, Double_t xup)
791799
792800// //////////////////////////////////////////////////////////////////////////////
793801// / Initialize axis with variable bins
802+ // /
803+ // / An error is printed if bin edges are not in strictly increasing order
794804
795805void TAxis::Set (Int_t nbins, const Float_t *xbins)
796806{
@@ -801,7 +811,7 @@ void TAxis::Set(Int_t nbins, const Float_t *xbins)
801811 fXbins .fArray [bin] = xbins[bin];
802812 for (bin=1 ; bin<= fNbins ; bin++)
803813 if (fXbins .fArray [bin] <= fXbins .fArray [bin - 1 ])
804- Error (" TAxis::Set" , " bins must be in increasing order" );
814+ Error (" TAxis::Set" , " bin edges must be in increasing order" );
805815 fXmin = fXbins .fArray [0 ];
806816 fXmax = fXbins .fArray [fNbins ];
807817 if (!fParent ) SetDefaults ();
0 commit comments