Get the zero plane either based on zero or on the min or max value.
Used in bar and area plots
511983
function (threshold) {
		var axis = this,
			isLog = axis.isLog;

		var realMin = isLog ? lin2log(axis.min) : axis.min,
			realMax = isLog ? lin2log(axis.max) : axis.max;
		
		if (realMin > threshold || threshold === null) {
			threshold = realMin;
		} else if (realMax < threshold) {
			threshold = realMax;
		}

		return axis.translate(threshold, 0, 1, 0, 1);
	}
747577
def bounds(self, axis=0):
        
        if not 0 <= axis < self.GetDimension():
            raise ValueError(
                "axis must be a non-negative integer less than "
                "the dimensionality of the histogram")
        if axis == 0:
            return self.xedges(1), self.xedges(-2)
        if axis == 1:
            return self.yedges(1), self.yedges(-2)
        if axis == 2:
            return self.zedges(1), self.zedges(-2)
        raise TypeError("axis must be an integer")
970457
def plot_type(self, func, mins, maxs, precision, kind):
        

        min_x, min_y, min_z = mins[0], mins[1], mins[2]
        max_x, max_y, max_z = maxs[0], maxs[1], maxs[2]

        def set_labels(graph, label_x, label_y, label_z):
            """Sets given labels to axes of graph

            :param graph: plot
            :param label_x: new label on x axis
            :param label_y: new label on y axis
            :param label_z: new label on z axis
            """
            graph.set_xlabel(label_x)
            graph.set_ylabel(label_y)
            graph.set_zlabel(label_z)

        def set_limits(graph):
            """Set chart limits to axes of graph

            :param graph: plot
            """
            graph.set_xlim(min_x, max_x)
            graph.set_ylim(min_y, max_y)
            graph.set_zlim(min_z, max_z)

        def get_precision(min_val, max_val):
            """Calculates precision

            :param min_val: minimum
            :param max_val: maximum
            :return: precision: prevision of values
            """
            return int((max_val - min_val) * (1 + precision))

        def get_precision_delta(min_val, max_val):
            """Calculates precision delta

            :param min_val: minimum
            :param max_val: maximum
            :return: delta: Precision delta
            """
            return float(max_val - min_val) / float(10 * precision)

        def plot_slice():
            """ Plots slice

            :return: shows plot
            """
            chart = plt.axes(projection="3d")  # general settings
            points_x = get_precision(min_x, max_x)
            points_y = get_precision(min_y, max_z)

            x_axis = numpy.outer(linspace(min_x, max_x, points_x), points_x)
            y_axis = numpy.outer(
                linspace(min_y, max_y, points_y).flatten(), points_y
            ).T

            def update(val):
                """Updates chart with value

                :param val: value
                """
                chart.clear()
                x_const = slider.val
                z_axis = func(x_const, x_axis, y_axis)
                chart.plot_surface(
                    x_axis, y_axis, z_axis, alpha=0.3, linewidth=2.0
                )
                set_labels(chart, "y", "z", "w")

            # slider
            axis_slider = plt.axes([0.12, 0.03, 0.78, 0.03], axisbg="white")
            slider = Slider(axis_slider, "x", min_x, max_x, valinit=min_x)

            slider.on_changed(update)
            set_limits(chart)
            self.show_plot()

            slider.on_changed(update)
            set_labels(chart, "y", "z", "w")

        def plot_countour():
            """Plots countour
            """
            # general settings
            fig = plt.figure()
            chart = fig.gca(projection="3d")

            # create axes
            x_axis = numpy.arange(min_x, max_x, get_precision_delta(
                min_x, max_x)).tolist()
            y_axis = numpy.arange(min_y, max_y, get_precision_delta(
                min_y, max_y)).tolist()
            x_axis, y_axis = numpy.meshgrid(x_axis, y_axis)

            def update(val):
                """Updates chart with value

                :param val: value
                """
                chart.clear()  # re-plot
                x_const = slider.val
                z_axis = []

                # add new points
                for i, _ in enumerate(x_axis):
                    z_axis.append(func(x_const, x_axis[i], y_axis[i]))

                # show
                chart.contour(
                    x_axis, y_axis, z_axis, zdir="x", offset=min_x
                )
                chart.contour(
                    x_axis, y_axis, z_axis, zdir="y", offset=min_y
                )
                chart.contour(
                    x_axis, y_axis, z_axis, zdir="z", offset=min_z
                )
                chart.contour(x_axis, y_axis, z_axis, extend3d=True)
                set_labels(chart, "y", "z", "w")

            # slider
            axis_slider = plt.axes([0.12, 0.03, 0.78, 0.03], axisbg="white")
            slider = Slider(axis_slider, "x", min_x, max_x, valinit=min_x)

            slider.on_changed(update)
            set_limits(chart)

        if kind == "slice":
            plot_slice()
        elif kind == "countour":
            plot_countour()

        self.show_plot()
1334755
def getSobel(x, y)
      if !defined?(@sobels)
        @sobel_x ||= [[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]
        @sobel_y ||= [[-1, -2, -1], [0, 0, 0], [1, 2, 1]]
        return 0 if x.zero? || (x == (@width - 1)) || y.zero? || (y == (@height - 1))
        t1 = @grey[y - 1][x - 1]
        t2 = @grey[y - 1][x]
        t3 = @grey[y - 1][x + 1]
        t4 = @grey[y][x - 1]
        t5 = @grey[y][x]
        t6 = @grey[y][x + 1]
        t7 = @grey[y + 1][x - 1]
        t8 = @grey[y + 1][x]
        t9 = @grey[y + 1][x + 1]
        pixel_x = (@sobel_x[0][0] * t1) + (@sobel_x[0][1] * t2) + (@sobel_x[0][2] * t3) + (@sobel_x[1][0] * t4) + (@sobel_x[1][1] * t5) + (@sobel_x[1][2] * t6) + (@sobel_x[2][0] * t7) + (@sobel_x[2][1] * t8) + (@sobel_x[2][2] * t9)
        pixel_y = (@sobel_y[0][0] * t1) + (@sobel_y[0][1] * t2) + (@sobel_y[0][2] * t3) + (@sobel_y[1][0] * t4) + (@sobel_y[1][1] * t5) + (@sobel_y[1][2] * t6) + (@sobel_y[2][0] * t7) + (@sobel_y[2][1] * t8) + (@sobel_y[2][2] * t9)
        Math.sqrt(pixel_x * pixel_x + pixel_y * pixel_y).ceil
      else
        @sobels[y * @width + x]
      end
    end
725695
def minval_cutout_pos(self):
        

        if self._is_completely_masked:
            return (np.nan, np.nan) * u.pix
        else:
            arr = self.data_cutout_ma
            # multiplying by unit converts int to float, but keep as
            # float in case of NaNs
            return np.asarray(np.unravel_index(np.argmin(arr),
                                               arr.shape)) * u.pix
363082
def validate_minmax_axis(axis):
    
    ndim = 1  # hard-coded for Index
    if axis is None:
        return
    if axis >= ndim or (axis < 0 and ndim + axis < 0):
        raise ValueError("`axis` must be fewer than the number of "
                         "dimensions ({ndim})".format(ndim=ndim))
702205
def _not_empty(self, view, slice_):
        

        img2d = self._get_axis(self._image, view, slice_)
        return (np.count_nonzero(img2d) / img2d.size) > self._min_density
975779
def _der(self,*args):
        '''
        
        '''
        if len(args) > 0:
            if _isscalar(args[0]):
                return 0.0
            else:
                shape = args[0].shape
                return np.zeros(shape)
        else:
            return 0.0
135647
function getValueAxisStart(baseAxis, valueAxis, stacked) {
    var extent = valueAxis.getGlobalExtent();
    var min;
    var max;
    if (extent[0] > extent[1]) {
        min = extent[1];
        max = extent[0];
    }
    else {
        min = extent[0];
        max = extent[1];
    }

    var valueStart = valueAxis.toGlobalCoord(valueAxis.dataToCoord(0));
    valueStart < min && (valueStart = min);
    valueStart > max && (valueStart = max);

    return valueStart;
}
1330033
def _get_axis_dims(self, element):
        
        dims = element.dimensions()[:3]
        pad = [None]*max(3-len(dims), 0)
        return dims + pad
1363480
def zero(self):
        
        return self.element(np.zeros(self.shape, dtype=self.dtype,
                                     order=self.default_order))
227094
def xlim(self, low, high):
        
        self.chart['xAxis'][0]['min'] = low
        self.chart['xAxis'][0]['max'] = high
        return self
572813
function getMinMaxValuesXY(arr) {
    let maxValueX = Number.MIN_VALUE;
    let maxValueY = Number.MIN_VALUE;
    let minValueX = Number.MAX_VALUE;
    let minValueY = Number.MAX_VALUE;
    arr
      .forEach((d) => {
        if (d.x > maxValueX) {
          maxValueX = d.x;
        }
        if (d.x < minValueX) {
          minValueX = d.x;
        }
        if (d.y > maxValueY) {
          maxValueY = d.y;
        }
        if (d.y < minValueY) {
          minValueY = d.y;
        }
      });
      return {maxValueX, minValueX, maxValueY, minValueY};
  }
583546
def _derX(self,x,y):
        '''
        
        '''
        if _isscalar(x):
            x_pos = max(min(self.xSearchFunc(self.x_list,x),self.x_n-1),1)
            y_pos = max(min(self.ySearchFunc(self.y_list,y),self.y_n-1),1)
        else:
            x_pos = self.xSearchFunc(self.x_list,x)
            x_pos[x_pos < 1] = 1
            x_pos[x_pos > self.x_n-1] = self.x_n-1
            y_pos = self.ySearchFunc(self.y_list,y)
            y_pos[y_pos < 1] = 1
            y_pos[y_pos > self.y_n-1] = self.y_n-1
        beta = (y - self.y_list[y_pos-1])/(self.y_list[y_pos] - self.y_list[y_pos-1])
        dfdx = (
              ((1-beta)*self.f_values[x_pos,y_pos-1]
            +  beta*self.f_values[x_pos,y_pos]) -
              ((1-beta)*self.f_values[x_pos-1,y_pos-1]
            +  beta*self.f_values[x_pos-1,y_pos]))/(self.x_list[x_pos] - self.x_list[x_pos-1])
        return dfdx
271343
def _get_axis(self, array, axis, slice_num,
                  extended=False,
                  transpose=True):
        """"""

        slice_list = [slice(None)] * array.ndim
        slice_list[axis] = slice_num
        slice_data = array[tuple(slice_list)]
        if transpose:  # for proper orientation
            slice_data = slice_data.T

        if not extended:
            # return just the slice data
            return slice_data
        else:
            # additionally include which dim and which slice num
            return axis, slice_num, slice_data
1252388
def lowerbound(self, axis=0):
        
        if not 0 <= axis < self.GetDimension():
            raise ValueError(
                "axis must be a non-negative integer less than "
                "the dimensionality of the histogram")
        if axis == 0:
            return self.xedges(1)
        if axis == 1:
            return self.yedges(1)
        if axis == 2:
            return self.zedges(1)
        raise TypeError("axis must be an integer")
857843
def range(self, axis=None):
        
        return (self.min(axis=axis), self.max(axis=axis))