code: def calcPgImagePlot2dDataRange(pgImagePlot2d, percentage, crossPlot):
      
      check_class(pgImagePlot2d.slicedArray, ArrayWithMask) # sanity check
  
      if crossPlot is None:
          array = pgImagePlot2d.slicedArray  # the whole image
  
      elif crossPlot == 'horizontal':
          if pgImagePlot2d.crossPlotRow is not None:
              array = pgImagePlot2d.slicedArray.asMaskedArray()[pgImagePlot2d.crossPlotRow, :]
          else:
              array = pgImagePlot2d.slicedArray # fall back on complete sliced array
  
      elif crossPlot == 'vertical':
          if pgImagePlot2d.crossPlotCol is not None:
              array = pgImagePlot2d.slicedArray.asMaskedArray()[:, pgImagePlot2d.crossPlotCol]
          else:
              array = pgImagePlot2d.slicedArray # fall back on complete sliced array
      else:
          raise ValueError("crossPlot must be: None, 'horizontal' or 'vertical', got: {}"
                           .format(crossPlot))
  
      return maskedNanPercentile(array, (percentage, 100-percentage) )
docs: Calculates the range from the inspectors' sliced array. Discards percentage of the minimum
          and percentage of the maximum values of the inspector.slicedArray
  
          :param pgImagePlot2d: the range methods will work on (the sliced array) of this inspector.
          :param percentage: percentage that will be discarded.
          :param crossPlot: if None, the range will be calculated from the entire sliced array,
              if "horizontal" or "vertical" the range will be calculated from the data under the
              horizontal or vertical cross hairs.
              If the cursor is outside the image, there is no valid data under the cross-hair and
              the range will be determined from the sliced array as a fall back.