code: def nbins(self, axis=0, overflow=False):
          
          if axis == 0:
              nbins = self.GetNbinsX()
          elif axis == 1:
              nbins = self.GetNbinsY()
          elif axis == 2:
              nbins = self.GetNbinsZ()
          else:
              raise ValueError("axis must be 0, 1, or 2")
          if overflow:
              nbins += 2
          return nbins
docs: Get the number of bins along an axis