Function to return a list of bounding boxes in data coordinates
    for a scatter plot
    Thank you to ImportanceOfBeingErnest
    https://stackoverflow.com/a/55007838/1304161
498130
def get_bboxes_pathcollection(sc, ax):
    """"""
#    ax.figure.canvas.draw() # need to draw before the transforms are set.
    transform = sc.get_transform()
    transOffset = sc.get_offset_transform()
    offsets = sc._offsets
    paths = sc.get_paths()
    transforms = sc.get_transforms()

    if not transform.is_affine:
        paths = [transform.transform_path_non_affine(p) for p in paths]
        transform = transform.get_affine()
    if not transOffset.is_affine:
        offsets = transOffset.transform_non_affine(offsets)
        transOffset = transOffset.get_affine()

    if isinstance(offsets, np.ma.MaskedArray):
        offsets = offsets.filled(np.nan)

    bboxes = []

    if len(paths) and len(offsets):
        if len(paths) < len(offsets):
            # for usual scatters you have one path, but several offsets
            paths = [paths[0]]*len(offsets)
        if len(transforms) < len(offsets):
            # often you may have a single scatter size, but several offsets
            transforms = [transforms[0]]*len(offsets)

        for p, o, t in zip(paths, offsets, transforms):
            result = get_path_collection_extents(
                transform.frozen(), [p], [t],
                [o], transOffset.frozen())
            bboxes.append(result.inverse_transformed(ax.transData))

    return bboxes
27294
def boundingbox(self):
        
        xyz = self.xyz
        return Box(mins=xyz.min(axis=0), maxs=xyz.max(axis=0))
782404
def get_surface_boundaries(self):
        
        min_lon, min_lat, max_lon, max_lat = self.get_bounding_box()
        return [[min_lon, max_lon]], [[min_lat, max_lat]]
730867
def pad_plots(plots):
    
    widths = []
    for row in plots:
        row_widths = []
        for p in row:
            width = pad_width(p)
            row_widths.append(width)
        widths.append(row_widths)
    plots = [[WidgetBox(p, width=w) if isinstance(p, (DataTable, Tabs)) else p
              for p, w in zip(row, ws)] for row, ws in zip(plots, widths)]
    return plots
769219
function dedupPoints (floatPoints, ratPoints, floatBounds) {
  var numPoints = ratPoints.length
  var uf = new UnionFind(numPoints)

  // Compute rational bounds
  var bounds = []
  for (var i = 0; i < ratPoints.length; ++i) {
    var p = ratPoints[i]
    var xb = boundRat(p[0])
    var yb = boundRat(p[1])
    bounds.push([
      nextafter(xb[0], -Infinity),
      nextafter(yb[0], -Infinity),
      nextafter(xb[1], Infinity),
      nextafter(yb[1], Infinity)
    ])
  }

  // Link all points with over lapping boxes
  boxIntersect(bounds, function (i, j) {
    uf.link(i, j)
  })

  // Do 1 pass over points to combine points in label sets
  var noDupes = true
  var labels = new Array(numPoints)
  for (var i = 0; i < numPoints; ++i) {
    var j = uf.find(i)
    if (j !== i) {
      // Clear no-dupes flag, zero out label
      noDupes = false
      // Make each point the top-left point from its cell
      floatPoints[j] = [
        Math.min(floatPoints[i][0], floatPoints[j][0]),
        Math.min(floatPoints[i][1], floatPoints[j][1])
      ]
    }
  }

  // If no duplicates, return null to signal termination
  if (noDupes) {
    return null
  }

  var ptr = 0
  for (var i = 0; i < numPoints; ++i) {
    var j = uf.find(i)
    if (j === i) {
      labels[i] = ptr
      floatPoints[ptr++] = floatPoints[i]
    } else {
      labels[i] = -1
    }
  }

  floatPoints.length = ptr

  // Do a second pass to fix up missing labels
  for (var i = 0; i < numPoints; ++i) {
    if (labels[i] < 0) {
      labels[i] = labels[uf.find(i)]
    }
  }

  // Return resulting union-find data structure
  return labels
}
719988
function computeBoundingBox(points) {

            if (points.length === 0) {
                return false;
            }

            var left = points[0].x;
            var right = points[0].x;
            var top = points[0].y;
            var bottom = points[0].y;

            for (var i = 1; i < points.length; i++) {
                var p = points[i];

                if (p.x < left) {
                    left = p.x;
                }

                if (p.x > right) {
                    right = p.x;
                }

                if (p.y < top) {
                    top = p.y;
                }

                if (p.y > bottom) {
                    bottom = p.y;
                }
            }

            return {
                x: left,
                y: top,
                width: right - left,
                height: bottom - top
            };
        }
1239759
def get_bounding_box_list_ghostscript(input_doc_fname, res_x, res_y, full_page_box):
    """"""

    if not gs_executable: init_and_test_gs_executable(exit_on_fail=True)
    res = str(res_x) + "x" + str(res_y)
    box_arg = "-dUseMediaBox" # should be default, but set anyway
    if "c" in full_page_box: box_arg = "-dUseCropBox"
    if "t" in full_page_box: box_arg = "-dUseTrimBox"
    if "a" in full_page_box: box_arg = "-dUseArtBox"
    if "b" in full_page_box: box_arg = "-dUseBleedBox" # may not be defined in gs
    gs_run_command = [gs_executable, "-dSAFER", "-dNOPAUSE", "-dBATCH", "-sDEVICE=bbox",
                    box_arg, "-r"+res, input_doc_fname]
    # Set printOutput to True for debugging or extra-verbose with Ghostscript's output.
    # Note Ghostscript writes the data to stderr, so the command below must capture it.
    try:
        gs_output = get_external_subprocess_output(gs_run_command,
                          print_output=False, indent_string="   ", env=gs_environment)
    except UnicodeDecodeError:
        print("\nError in pdfCropMargins:  In attempting to get the bounding boxes"
              "\nGhostscript encountered characters which cannot be decoded by the"
              "\n'utf-8' codec.",
              file=sys.stderr)
        cleanup_and_exit(1)

    bounding_box_list = []
    for line in gs_output:
        split_line = line.split()
        if split_line and split_line[0] == r"%%HiResBoundingBox:":
            del split_line[0]
            if len(split_line) != 4:
                print("\nWarning from pdfCropMargins: Ignoring this unparsable line"
                      "\nwhen finding the bounding boxes with Ghostscript:",
                      line, "\n", file=sys.stderr)
                continue
            # Note gs reports values in order left, bottom, right, top,
            # i.e., lower left point followed by top right point.
            bounding_box_list.append([float(split_line[0]),
                                    float(split_line[1]),
                                    float(split_line[2]),
                                    float(split_line[3])])

    if not bounding_box_list:
        print("\nError in pdfCropMargins: Ghostscript failed to find any bounding"
              "\nboxes in the document.", file=sys.stderr)
        cleanup_and_exit(1)
    return bounding_box_list
774389
def bounds(self) -> Tuple[float, float, float, float]:
        
        return self.shape.bounds
1320761
function getMouseCoordinates(e) {
			var coordinates = {
				xAxis: [],
				yAxis: []
			};
			each(axes, function (axis) {
				var translate = axis.translate,
					isXAxis = axis.isXAxis,
					isHorizontal = inverted ? !isXAxis : isXAxis;

				coordinates[isXAxis ? 'xAxis' : 'yAxis'].push({
					axis: axis,
					value: translate(
						isHorizontal ?
							e.chartX - plotLeft  :
							plotHeight - e.chartY + plotTop,
						true
					)
				});
			});
			return coordinates;
		}
32744
def _parse_bbox_list(bbox_list):
        
        if isinstance(bbox_list, BBoxCollection):
            return bbox_list.bbox_list, bbox_list.crs

        if not isinstance(bbox_list, list) or not bbox_list:
            raise ValueError('Expected non-empty list of BBox objects')

        for bbox in bbox_list:
            if not isinstance(bbox, BBox):
                raise ValueError('Elements in the list should be of type {}, got {}'.format(BBox.__name__, type(bbox)))

        crs = bbox_list[0].crs
        for bbox in bbox_list:
            if bbox.crs is not crs:
                raise ValueError('All bounding boxes should have the same CRS')

        return bbox_list, crs
427481
def bounding_boxes(self):
        

        cos_theta = np.cos(self.theta)
        sin_theta = np.sin(self.theta)
        ax = self.a_out * cos_theta
        ay = self.a_out * sin_theta
        bx = self.b_out * -sin_theta
        by = self.b_out * cos_theta
        dx = np.sqrt(ax*ax + bx*bx)
        dy = np.sqrt(ay*ay + by*by)

        xmin = self.positions[:, 0] - dx
        xmax = self.positions[:, 0] + dx
        ymin = self.positions[:, 1] - dy
        ymax = self.positions[:, 1] + dy

        return [BoundingBox._from_float(x0, x1, y0, y1)
                for x0, x1, y0, y1 in zip(xmin, xmax, ymin, ymax)]
388241
def bounding_box(self):
        
        if self.world_coords:
            return self.world_obj.findSolid().BoundingBox()
        return self.local_obj.findSolid().BoundingBox()
587708
def calc_bounds(xy, entity):
    
    left, top = xy
    right, bottom = left + entity.width, top + entity.height
    return [left, top, right, bottom]
1320099
def bounding_boxes(self):
        

        w2 = self.w_out / 2.
        h2 = self.h_out / 2.
        cos_theta = math.cos(self.theta)
        sin_theta = math.sin(self.theta)
        dx1 = abs(w2 * cos_theta - h2 * sin_theta)
        dy1 = abs(w2 * sin_theta + h2 * cos_theta)
        dx2 = abs(w2 * cos_theta + h2 * sin_theta)
        dy2 = abs(w2 * sin_theta - h2 * cos_theta)
        dx = max(dx1, dx2)
        dy = max(dy1, dy2)

        xmin = self.positions[:, 0] - dx
        xmax = self.positions[:, 0] + dx
        ymin = self.positions[:, 1] - dy
        ymax = self.positions[:, 1] + dy

        return [BoundingBox._from_float(x0, x1, y0, y1)
                for x0, x1, y0, y1 in zip(xmin, xmax, ymin, ymax)]
486995
function () {
            var p = this.padding,
                w = this.canvas.width,
                h = this.canvas.height * 0.5;

            return [{
                left: w * (this.bezier.coordinates[0]     * (1 - p[3] - p[1]) - p[3]) + "px",
                top:  h * (1 - this.bezier.coordinates[1] * (1 - p[0] - p[2]) - p[0]) + "px"
            }, {
                left: w * (this.bezier.coordinates[2]     * (1 - p[3] - p[1]) - p[3]) + "px",
                top:  h * (1 - this.bezier.coordinates[3] * (1 - p[0] - p[2]) - p[0]) + "px"
            }];
        }
159315
def get_bbox(self, points=None):
        
        if points is None:
            x1, y1, x2, y2 = self.get_llur()
            return ((x1, y1), (x1, y2), (x2, y2), (x2, y1))
        else:
            return trcalc.strip_z(trcalc.get_bounds(points))
1255806
function computePathBoundingBox(path) {

            var points = [];
            var iterator = function (c, p0, p1, p2) {
                if (c === 'L') {
                    points.push(p0);
                    points.push(p1);
                }
                else if (c === 'Q') {
                    var bound = computeQuadraticBezierBoundingBox(p0, p1, p2);

                    points.push(bound);
                    points.push({
                        x: bound.x + bound.width,
                        y: bound.y + bound.height
                    });
                }
            };

            if (arguments.length === 1) {
                pathIterator(path, function (c, p0, p1, p2) {
                    if (c === 'L') {
                        points.push(p0);
                        points.push(p1);
                    }
                    else if (c === 'Q') {
                        var bound = computeQuadraticBezierBoundingBox(p0, p1, p2);

                        points.push(bound);
                        points.push({
                            x: bound.x + bound.width,
                            y: bound.y + bound.height
                        });
                    }
                });
            }
            else {
                for (var i = 0, l = arguments.length; i < l; i++) {
                    pathIterator(arguments[i], iterator);
                }
            }

            return computeBoundingBox(points);
        }