code: def robust_data_range(arr, robust=False, vmin=None, vmax=None):
          
          # from the seaborn code 
          # https://github.com/mwaskom/seaborn/blob/3a3ec75befab52c02650c62772a90f8c23046038/seaborn/matrix.py#L201
  
          def _get_vmin_vmax(arr2d, vmin=None, vmax=None):
              if vmin is None:
                  vmin = np.percentile(arr2d, 2) if robust else arr2d.min()
              if vmax is None:
                  vmax = np.percentile(arr2d, 98) if robust else arr2d.max()
              return vmin, vmax
  
          if len(arr.shape) == 3 and vmin is None and vmax is None:
              vmin = []
              vmax = []
              for i in range(arr.shape[2]):
                  arr_i = arr[:, :, i]
                  vmin_i, vmax_i = _get_vmin_vmax(arr_i, vmin=None, vmax=None)
                  vmin.append(vmin_i)
                  vmax.append(vmax_i)
          else:
              vmin, vmax = _get_vmin_vmax(arr, vmin=vmin, vmax=vmax)
          return vmin, vmax
docs: Get a robust data range, i.e. 2nd and 98th percentile for vmin, vmax parameters.