original_docstring:  Add scalebars to axes
      Adds a set of scale bars to *ax*, matching the size to the ticks of the plot
      and optionally hiding the x and y axes
  
      Args:
        ax : the axis to attach ticks to
        matchx,matchy : if True, set size of scale bars to spacing between ticks
                      if False, size should be set using sizex and sizey params
        hidex,hidey : if True, hide x-axis and y-axis of parent
        **kwargs : additional arguments passed to AnchoredScaleBars
  
      Returns:
        created scalebar object
      
docstring: Add scalebars to axes
  Adds a set of scale bars to *ax*, matching the size to the ticks of the plot
  and optionally hiding the x and y axes
docstring_tokens: Add scalebars to axes Adds a set of scale bars to * ax * matching the size to the ticks of the plot and optionally hiding the x and y axes
code: def add_scalebar( ax, matchx=True, matchy=True, hidex=True, hidey=True, **kwargs ):
      """ Add scalebars to axes
      Adds a set of scale bars to *ax*, matching the size to the ticks of the plot
      and optionally hiding the x and y axes
  
      Args:
        ax : the axis to attach ticks to
        matchx,matchy : if True, set size of scale bars to spacing between ticks
                      if False, size should be set using sizex and sizey params
        hidex,hidey : if True, hide x-axis and y-axis of parent
        **kwargs : additional arguments passed to AnchoredScaleBars
  
      Returns:
        created scalebar object
      """
      def f(axis):
          l = axis.get_majorticklocs()
          return len(l)>1 and (l[1] - l[0])
      
      if matchx:
          kwargs['sizex'] = f(ax.xaxis)
          kwargs['labelx'] = str(kwargs['sizex'])
      if matchy:
          kwargs['sizey'] = f(ax.yaxis)
          kwargs['labely'] = str(kwargs['sizey'])
          
      sb = AnchoredScaleBar(ax.transData, **kwargs)
      ax.add_artist(sb)
  
      if hidex : ax.xaxis.set_visible(False)
      if hidey : ax.yaxis.set_visible(False)
  
      return sb
code_tokens: def add_scalebar ( ax , matchx = True , matchy = True , hidex = True , hidey = True , ** kwargs ) : def f ( axis ) : l = axis . get_majorticklocs ( ) return len ( l ) > 1 and ( l [ 1 ] - l [ 0 ] ) if matchx : kwargs [ 'sizex' ] = f ( ax . xaxis ) kwargs [ 'labelx' ] = str ( kwargs [ 'sizex' ] ) if matchy : kwargs [ 'sizey' ] = f ( ax . yaxis ) kwargs [ 'labely' ] = str ( kwargs [ 'sizey' ] ) sb = AnchoredScaleBar ( ax . transData , ** kwargs ) ax . add_artist ( sb ) if hidex : ax . xaxis . set_visible ( False ) if hidey : ax . yaxis . set_visible ( False ) return sb
short_docstring: Add scalebars to axes
  Adds a set of scale bars to *ax*, matching the size to the ticks of the plot
  and optionally hiding the x and y axes
short_docstring_tokens: Add scalebars to axes Adds a set of scale bars to * ax * matching the size to the ticks of the plot and optionally hiding the x and y axes
comment: """ Add scalebars to axes
      Adds a set of scale bars to *ax*, matching the size to the ticks of the plot
      and optionally hiding the x and y axes
  
      Args:
        ax : the axis to attach ticks to
        matchx,matchy : if True, set size of scale bars to spacing between ticks
                      if False, size should be set using sizex and sizey params
        hidex,hidey : if True, hide x-axis and y-axis of parent
        **kwargs : additional arguments passed to AnchoredScaleBars
  
      Returns:
        created scalebar object
      """