code: def create_hexbin_mapbox(
      data_frame=None,
      lat=None,
      lon=None,
      color=None,
      nx_hexagon=5,
      agg_func=None,
      animation_frame=None,
      color_discrete_sequence=None,
      color_discrete_map={},
      labels={},
      color_continuous_scale=None,
      range_color=None,
      color_continuous_midpoint=None,
      opacity=None,
      zoom=None,
      center=None,
      mapbox_style=None,
      title=None,
      template=None,
      width=None,
      height=None,
      min_count=None,
      show_original_data=False,
      original_data_marker=None,
  ):
      """
      Returns a figure aggregating scattered points into connected hexagons
      """
      args = build_dataframe(args=locals(), constructor=None)
  
      if agg_func is None:
          agg_func = np.mean
  
      lat_range = (
          args["data_frame"][args["lat"]].agg(["min", "max"]).values
      )
      lon_range = (
          args["data_frame"][args["lon"]].agg(["min", "max"]).values
      )
  
      (
          hexagons_lats,
          hexagons_lons,
          hexagons_ids,
          count,
      ) = _compute_wgs84_hexbin(
          lat=args["data_frame"][args["lat"]].values,
          lon=args["data_frame"][args["lon"]].values,
          lat_range=lat_range,
          lon_range=lon_range,
          color=None,
          nx=nx_hexagon,
          agg_func=agg_func,
          min_count=min_count,
      )
  
      geojson = _hexagons_to_geojson(
          hexagons_lats, hexagons_lons, hexagons_ids
      )
  
      if zoom is None:
          if height is None and width is None:
              mapDim = dict(height=450, width=450)
          elif height is None and width is not None:
              mapDim = dict(height=450, width=width)
          elif height is not None and width is None:
              mapDim = dict(height=height, width=height)
          else:
              mapDim = dict(height=height, width=width)
          zoom = _getBoundsZoomLevel(
              lon_range[0],
              lon_range[1],
              lat_range[0],
              lat_range[1],
              mapDim,
          )
  
      if center is None:
          center = dict(lat=lat_range.mean(), lon=lon_range.mean())
  
      if args["animation_frame"] is not None:
          groups = (
              args["data_frame"].groupby(args["animation_frame"]).groups
          )
      else:
          groups = {0: args["data_frame"].index}
  
      agg_data_frame_list = []
      for frame, index in groups.items():
          df = args["data_frame"].loc[index]
          _, _, hexagons_ids, aggregated_value = _compute_wgs84_hexbin(
              lat=df[args["lat"]].values,
              lon=df[args["lon"]].values,
              lat_range=lat_range,
              lon_range=lon_range,
              color=df[args["color"]].values if args["color"] else None,
              nx=nx_hexagon,
              agg_func=agg_func,
              min_count=min_count,
          )
          agg_data_frame_list.append(
              pd.DataFrame(
                  np.c_[hexagons_ids, aggregated_value],
                  columns=["locations", "color"],
              )
          )
      agg_data_frame = (
          pd.concat(agg_data_frame_list, axis=0, keys=groups.keys())
          .rename_axis(index=("frame", "index"))
          .reset_index("frame")
      )
  
      agg_data_frame["color"] = pd.to_numeric(agg_data_frame["color"])
  
      if range_color is None:
          range_color = [
              agg_data_frame["color"].min(),
              agg_data_frame["color"].max(),
          ]
  
      fig = choropleth_mapbox(
          data_frame=agg_data_frame,
          geojson=geojson,
          locations="locations",
          color="color",
          hover_data={
              "color": True,
              "locations": False,
              "frame": False,
          },
          animation_frame=(
              "frame" if args["animation_frame"] is not None else None
          ),
          color_discrete_sequence=color_discrete_sequence,
          color_discrete_map=color_discrete_map,
          labels=labels,
          color_continuous_scale=color_continuous_scale,
          range_color=range_color,
          color_continuous_midpoint=color_continuous_midpoint,
          opacity=opacity,
          zoom=zoom,
          center=center,
          mapbox_style=mapbox_style,
          title=title,
          template=template,
          width=width,
          height=height,
      )
  
      if show_original_data:
          original_fig = scatter_mapbox(
              data_frame=(
                  args["data_frame"].sort_values(
                      by=args["animation_frame"]
                  )
                  if args["animation_frame"] is not None
                  else args["data_frame"]
              ),
              lat=args["lat"],
              lon=args["lon"],
              animation_frame=args["animation_frame"],
          )
          original_fig.data[0].hoverinfo = "skip"
          original_fig.data[0].hovertemplate = None
          original_fig.data[0].marker = original_data_marker
  
          fig.add_trace(original_fig.data[0])
  
          if args["animation_frame"] is not None:
              for i in range(len(original_fig.frames)):
                  original_fig.frames[i].data[0].hoverinfo = "skip"
                  original_fig.frames[i].data[0].hovertemplate = None
                  original_fig.frames[i].data[
                      0
                  ].marker = original_data_marker
  
                  fig.frames[i].data = [
                      fig.frames[i].data[0],
                      original_fig.frames[i].data[0],
                  ]
  
      return fig
  
file_path: catboost/contrib/python/plotly/py2/plotly/figure_factory/_hexbin_mapbox.py
imports: from plotly.express._core import build_dataframe
  from plotly.express._doc import make_docstring
  from plotly.express._chart_types import choropleth_mapbox, scatter_mapbox
  import numpy
  import pandas
label_desc: Use image node_id 7 for calling a global function with example usage: create_hexbin_mapbox(data_frame, lat, lon, color, nx_hexagon, agg_func, animation_frame, color_discrete_sequence, color_discrete_map, labels, color_continuous_scale, range_color, color_continuous_midpoint, opacity, zoom, center, mapbox_style, title, template, width, height, min_count, show_original_data, original_data_marker) and returns: fig