docs: def crop_by_percent(cmap, per, which='both', N=None):
      '''Crop end or ends of a colormap by per percent.
  
      :param cmap: A colormap object, like cmocean.cm.matter.
      :param per: Percent of colormap to remove. If which=='both', take this
          percent off both ends of colormap. If which=='min' or which=='max',
          take percent only off the specified end of colormap.
      :param which='both': which end or ends of colormap to cut off. which='both'
          removes from both ends, which='min' from bottom end, and which='max'
          from top end.
      :param N=None: User can specify the number of rows for the outgoing colormap.
          If unspecified, N from incoming colormap will be used and values will
          be interpolated as needed to fill in rows.
  
      Outputs resultant colormap object.
  
      This is a wrapper around crop() to make it easier to use for cropping
          based on percent.
  
      Examples:
          # example with oxy map: cut off yellow part which is top 20%
          # compare with full colormap
          vmin = 0; vmax = 10; pivot = 5
          A = np.random.randint(vmin, vmax, (5,5))
          fig, axes = plt.subplots(1, 2)
          mappable = axes[0].pcolormesh(A, vmin=vmin, vmax=vmax, cmap=cmocean.cm.oxy)
          fig.colorbar(mappable, ax=axes[0])
          vmin = 0; vmax = 8; pivot = 5
          newcmap = crop_by_percent(cmocean.cm.oxy, 20, which='max', N=None)
          plt.figure()
          plt.pcolormesh(A, vmin=vmin, vmax=vmax, cmap=newcmap)
          plt.colorbar()
  
          # example with oxy map: cut off red part which is bottom 20%
          # compare with full colormap
          vmin = 0; vmax = 10; pivot = 5
          A = np.random.randint(vmin, vmax, (5,5))
          fig, axes = plt.subplots(1, 2)
          mappable = axes[0].pcolormesh(A, vmin=vmin, vmax=vmax, cmap=cmocean.cm.oxy)
          fig.colorbar(mappable, ax=axes[0])
          vmin = 2; vmax = 10; pivot = 5
          A = np.random.randint(vmin, vmax, (5,5))
          newcmap = crop_by_percent(cmocean.cm.oxy, 20, which='min', N=None)
          plt.figure()
          plt.pcolormesh(A, vmin=vmin, vmax=vmax, cmap=newcmap)
          plt.colorbar()
  
          # crop both dark ends off colormap to reduce range
          newcmap = crop_by_percent(cmocean.cm.balance, 10, which='both', N=None)
          plt.figure()
          A = np.random.randint(-5, 5, (5,5))
          plt.pcolormesh(A, vmin=vmin, vmax=vmax, cmap=newcmap)
          plt.colorbar()
  
      '''
  
      if which == 'both':  # take percent off both ends of cmap
          vmin = -100; vmax = 100; pivot = 0
          dmax = per
  
      elif which == 'min':  # take percent off bottom of cmap
          vmax = 10; pivot = 5
          vmin = (0 + per/100)*2*pivot
          dmax = None
  
      elif which == 'max':  # take percent off top of cmap
          vmin = 0; pivot = 5
          vmax = (1 - per/100)*2*pivot
          dmax = None
  
      newcmap = crop(cmap, vmin, vmax, pivot, dmax=dmax, N=N)
  
      return newcmap