code: def bovy_hist(x,xlabel=None,ylabel=None,overplot=False,**kwargs):
      
      if not overplot:
          pyplot.figure()
      if 'xrange' in kwargs:
          xlimits= kwargs.pop('xrange')
          if not 'range' in kwargs:
              kwargs['range']= xlimits
          xrangeSet= True
      else: xrangeSet= False
      if 'yrange' in kwargs:
          ylimits= kwargs.pop('yrange')
          yrangeSet= True
      else: yrangeSet= False
      out= pyplot.hist(x,**kwargs)
      if overplot: return out
      _add_axislabels(xlabel,ylabel)
      if not 'range' in kwargs and not xrangeSet:
          if isinstance(x,list):
              xlimits=(sc.array(x).min(),sc.array(x).max())
          else:
              pyplot.xlim(x.min(),x.max())
      elif xrangeSet:
          pyplot.xlim(xlimits)
      else:
          pyplot.xlim(kwargs['range'])
      if yrangeSet:
          pyplot.ylim(ylimits)
      _add_ticks()
      return out
docs: NAME:
  
         bovy_hist
  
      PURPOSE:
  
         wrapper around matplotlib's hist function
  
      INPUT:
  
         x - array to histogram
  
         xlabel - (raw string!) x-axis label, LaTeX math mode, no $s needed
  
         ylabel - (raw string!) y-axis label, LaTeX math mode, no $s needed
  
         yrange - set the y-axis range
  
         +all pyplot.hist keywords
  
      OUTPUT:
         (from the matplotlib docs:
         http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.hist)
  
         The return value is a tuple (n, bins, patches)
         or ([n0, n1, ...], bins, [patches0, patches1,...])
         if the input contains multiple data
  
      HISTORY:
  
         2009-12-23 - Written - Bovy (NYU)