class_docstr: Create a new figure for plotting.
  
  A subclass of |Plot| that simplifies plot creation with default axes, grids,
  tools, etc.
  
  Figure objects have many glyph methods that can be used to draw
  vectorized graphical glyphs:
  
  .. hlist::
      :columns: 3
  
      * :func:`~bokeh.plotting.figure.annular_wedge`
      * :func:`~bokeh.plotting.figure.annulus`
      * :func:`~bokeh.plotting.figure.arc`
      * :func:`~bokeh.plotting.figure.asterisk`
      * :func:`~bokeh.plotting.figure.bezier`
      * :func:`~bokeh.plotting.figure.circle`
      * :func:`~bokeh.plotting.figure.circle_cross`
      * :func:`~bokeh.plotting.figure.circle_dot`
      * :func:`~bokeh.plotting.figure.circle_x`
      * :func:`~bokeh.plotting.figure.circle_y`
      * :func:`~bokeh.plotting.figure.cross`
      * :func:`~bokeh.plotting.figure.dash`
      * :func:`~bokeh.plotting.figure.diamond`
      * :func:`~bokeh.plotting.figure.diamond_cross`
      * :func:`~bokeh.plotting.figure.diamond_dot`
      * :func:`~bokeh.plotting.figure.dot`
      * :func:`~bokeh.plotting.figure.ellipse`
      * :func:`~bokeh.plotting.figure.harea`
      * :func:`~bokeh.plotting.figure.harea_step`
      * :func:`~bokeh.plotting.figure.hbar`
      * :func:`~bokeh.plotting.figure.hex`
      * :func:`~bokeh.plotting.figure.hex_tile`
      * :func:`~bokeh.plotting.figure.hstrip`
      * :func:`~bokeh.plotting.figure.hspan`
      * :func:`~bokeh.plotting.figure.image`
      * :func:`~bokeh.plotting.figure.image_rgba`
      * :func:`~bokeh.plotting.figure.image_url`
      * :func:`~bokeh.plotting.figure.inverted_triangle`
      * :func:`~bokeh.plotting.figure.line`
      * :func:`~bokeh.plotting.figure.multi_line`
      * :func:`~bokeh.plotting.figure.multi_polygons`
      * :func:`~bokeh.plotting.figure.patch`
      * :func:`~bokeh.plotting.figure.patches`
      * :func:`~bokeh.plotting.figure.plus`
      * :func:`~bokeh.plotting.figure.quad`
      * :func:`~bokeh.plotting.figure.quadratic`
      * :func:`~bokeh.plotting.figure.ray`
      * :func:`~bokeh.plotting.figure.rect`
      * :func:`~bokeh.plotting.figure.segment`
      * :func:`~bokeh.plotting.figure.square`
      * :func:`~bokeh.plotting.figure.square_cross`
      * :func:`~bokeh.plotting.figure.square_dot`
      * :func:`~bokeh.plotting.figure.square_pin`
      * :func:`~bokeh.plotting.figure.square_x`
      * :func:`~bokeh.plotting.figure.star`
      * :func:`~bokeh.plotting.figure.star_dot`
      * :func:`~bokeh.plotting.figure.step`
      * :func:`~bokeh.plotting.figure.text`
      * :func:`~bokeh.plotting.figure.triangle`
      * :func:`~bokeh.plotting.figure.triangle_dot`
      * :func:`~bokeh.plotting.figure.triangle_pin`
      * :func:`~bokeh.plotting.figure.varea`
      * :func:`~bokeh.plotting.figure.varea_step`
      * :func:`~bokeh.plotting.figure.vbar`
      * :func:`~bokeh.plotting.figure.vstrip`
      * :func:`~bokeh.plotting.figure.vspan`
      * :func:`~bokeh.plotting.figure.wedge`
      * :func:`~bokeh.plotting.figure.x`
      * :func:`~bokeh.plotting.figure.y`
  
  There is a scatter function that can be parameterized by marker type:
  
  * :func:`~bokeh.plotting.figure.scatter`
  
  There are also specialized methods for stacking bars:
  
  * bars: :func:`~bokeh.plotting.figure.hbar_stack`, :func:`~bokeh.plotting.figure.vbar_stack`
  * lines: :func:`~bokeh.plotting.figure.hline_stack`, :func:`~bokeh.plotting.figure.vline_stack`
  * areas: :func:`~bokeh.plotting.figure.harea_stack`, :func:`~bokeh.plotting.figure.varea_stack`
  
  As well as one specialized method for making simple hexbin plots:
  
  * :func:`~bokeh.plotting.figure.hexbin`
  
  In addition to all the ``figure`` property attributes, the following
  options are also accepted:
  
  .. bokeh-options:: FigureOptions
      :module: bokeh.plotting._figure
docstr: Perform a simple equal-weight hexagonal binning.
  
  A :class:`~bokeh.models.glyphs.HexTile` glyph will be added to display
  the binning. The :class:`~bokeh.models.sources.ColumnDataSource` for
  the glyph will have columns ``q``, ``r``, and ``count``, where ``q``
  and ``r`` are `axial coordinates`_ for a tile, and ``count`` is the
  associated bin count.
  
  It is often useful to set ``match_aspect=True`` on the associated plot,
  so that hexagonal tiles are all regular (i.e. not "stretched") in
  screen space.
  
  For more sophisticated use-cases, e.g. weighted binning or individually
  scaling hex tiles, use :func:`hex_tile` directly, or consider a higher
  level library such as HoloViews.
  
  Args:
      x (array[float]) :
          A NumPy array of x-coordinates to bin into hexagonal tiles.
  
      y (array[float]) :
          A NumPy array of y-coordinates to bin into hexagonal tiles.
  
      size (float) :
          The size of the hexagonal tiling to use. The size is defined as
          distance from the center of a hexagon to a corner.
  
          In case the aspect scaling is not 1-1, then specifically `size`
          is the distance from the center to the "top" corner with the
          `"pointytop"` orientation, and the distance from the center to
          a "side" corner with the "flattop" orientation.
  
      orientation ("pointytop" or "flattop", optional) :
          Whether the hexagonal tiles should be oriented with a pointed
          corner on top, or a flat side on top. (default: "pointytop")
  
      palette (str or seq[color], optional) :
          A palette (or palette name) to use to colormap the bins according
          to count. (default: 'Viridis256')
  
          If ``fill_color`` is supplied, it overrides this value.
  
      line_color (color, optional) :
          The outline color for hex tiles, or None (default: None)
  
      fill_color (color, optional) :
          An optional fill color for hex tiles, or None. If None, then
          the ``palette`` will be used to color map the tiles by
          count. (default: None)
  
      aspect_scale (float) :
          Match a plot's aspect ratio scaling.
  
          When working with a plot with ``aspect_scale != 1``, this
          parameter can be set to match the plot, in order to draw
          regular hexagons (instead of "stretched" ones).
  
          This is roughly equivalent to binning in "screen space", and
          it may be better to use axis-aligned rectangular bins when
          plot aspect scales are not one.
  
  Any additional keyword arguments are passed to :func:`hex_tile`.
  
  Returns:
      (Glyphrender, DataFrame)
          A tuple with the ``HexTile`` renderer generated to display the
          binning, and a Pandas ``DataFrame`` with columns ``q``, ``r``,
          and ``count``, where ``q`` and ``r`` are `axial coordinates`_
          for a tile, and ``count`` is the associated bin count.
  
  Example:
  
      .. bokeh-plot::
          :source-position: above
  
          import numpy as np
          from bokeh.models import HoverTool
          from bokeh.plotting import figure, show
  
          x = 2 + 2*np.random.standard_normal(500)
          y = 2 + 2*np.random.standard_normal(500)
  
          p = figure(match_aspect=True, tools="wheel_zoom,reset")
          p.background_fill_color = '#440154'
          p.grid.visible = False
  
          p.hexbin(x, y, size=0.5, hover_color="pink", hover_alpha=0.8)
  
          hover = HoverTool(tooltips=[("count", "@c"), ("(q,r)", "(@q, @r)")])
          p.add_tools(hover)
  
          show(p)
  
  .. _axial coordinates: https://www.redblobgames.com/grids/hexagons/#coordinates-axial
code: def hexbin(
      self,
      x,
      y,
      size,
      orientation="pointytop",
      palette="Viridis256",
      line_color=None,
      fill_color=None,
      aspect_scale=1,
      **kwargs,
  ):
      """Perform a simple equal-weight hexagonal binning.
  
      A :class:`~bokeh.models.glyphs.HexTile` glyph will be added to display
      the binning. The :class:`~bokeh.models.sources.ColumnDataSource` for
      the glyph will have columns ``q``, ``r``, and ``count``, where ``q``
      and ``r`` are `axial coordinates`_ for a tile, and ``count`` is the
      associated bin count.
  
      It is often useful to set ``match_aspect=True`` on the associated plot,
      so that hexagonal tiles are all regular (i.e. not "stretched") in
      screen space.
  
      For more sophisticated use-cases, e.g. weighted binning or individually
      scaling hex tiles, use :func:`hex_tile` directly, or consider a higher
      level library such as HoloViews.
  
      Args:
          x (array[float]) :
              A NumPy array of x-coordinates to bin into hexagonal tiles.
  
          y (array[float]) :
              A NumPy array of y-coordinates to bin into hexagonal tiles.
  
          size (float) :
              The size of the hexagonal tiling to use. The size is defined as
              distance from the center of a hexagon to a corner.
  
              In case the aspect scaling is not 1-1, then specifically `size`
              is the distance from the center to the "top" corner with the
              `"pointytop"` orientation, and the distance from the center to
              a "side" corner with the "flattop" orientation.
  
          orientation ("pointytop" or "flattop", optional) :
              Whether the hexagonal tiles should be oriented with a pointed
              corner on top, or a flat side on top. (default: "pointytop")
  
          palette (str or seq[color], optional) :
              A palette (or palette name) to use to colormap the bins according
              to count. (default: 'Viridis256')
  
              If ``fill_color`` is supplied, it overrides this value.
  
          line_color (color, optional) :
              The outline color for hex tiles, or None (default: None)
  
          fill_color (color, optional) :
              An optional fill color for hex tiles, or None. If None, then
              the ``palette`` will be used to color map the tiles by
              count. (default: None)
  
          aspect_scale (float) :
              Match a plot's aspect ratio scaling.
  
              When working with a plot with ``aspect_scale != 1``, this
              parameter can be set to match the plot, in order to draw
              regular hexagons (instead of "stretched" ones).
  
              This is roughly equivalent to binning in "screen space", and
              it may be better to use axis-aligned rectangular bins when
              plot aspect scales are not one.
  
      Any additional keyword arguments are passed to :func:`hex_tile`.
  
      Returns:
          (Glyphrender, DataFrame)
              A tuple with the ``HexTile`` renderer generated to display the
              binning, and a Pandas ``DataFrame`` with columns ``q``, ``r``,
              and ``count``, where ``q`` and ``r`` are `axial coordinates`_
              for a tile, and ``count`` is the associated bin count.
  
      Example:
  
          .. bokeh-plot::
              :source-position: above
  
              import numpy as np
              from bokeh.models import HoverTool
              from bokeh.plotting import figure, show
  
              x = 2 + 2*np.random.standard_normal(500)
              y = 2 + 2*np.random.standard_normal(500)
  
              p = figure(match_aspect=True, tools="wheel_zoom,reset")
              p.background_fill_color = '#440154'
              p.grid.visible = False
  
              p.hexbin(x, y, size=0.5, hover_color="pink", hover_alpha=0.8)
  
              hover = HoverTool(tooltips=[("count", "@c"), ("(q,r)", "(@q, @r)")])
              p.add_tools(hover)
  
              show(p)
  
      .. _axial coordinates: https://www.redblobgames.com/grids/hexagons/#coordinates-axial
  
      """
      from ..util.hex import hexbin
  
      bins = hexbin(x, y, size, orientation, aspect_scale=aspect_scale)
  
      if fill_color is None:
          fill_color = linear_cmap("c", palette, 0, max(bins.counts))
  
      source = ColumnDataSource(
          data=dict(q=bins.q, r=bins.r, c=bins.counts)
      )
  
      r = self.hex_tile(
          q="q",
          r="r",
          size=size,
          orientation=orientation,
          aspect_scale=aspect_scale,
          source=source,
          line_color=line_color,
          fill_color=fill_color,
          **kwargs,
      )
  
      return (r, bins)
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING
  import logging
  import numpy
  from ..core.enums import HorizontalLocation, MarkerType, VerticalLocation
  from ..core.properties import Auto, Datetime, Either, Enum, Float, Instance, InstanceDefault, Int, List, Nullable, Object, Seq, String, TextLike, TimeDelta, Tuple
  from ..models import ColumnDataSource, CoordinateMapping, DataRange1d, GraphRenderer, LayoutProvider, Plot, Range, Scale, Tool
  from ..models.dom import Template
  from ..models.tools import Drag, GestureTool, InspectTool, Scroll, Tap
  from ..transform import linear_cmap
  from ..util.options import Options
  from ._graph import get_graph_kwargs
  from ._plot import get_range, get_scale, process_axis_and_grid
  from ._stack import double_stack, single_stack
  from ._tools import process_active_tools, process_tools_arg
  from .contour import ContourRenderer, from_contour
  from .glyph_api import _MARKER_SHORTCUTS, GlyphAPI
label_desc: Use image node_id 5 for calling the figure obj's underlying member method code with example usage: obj.hexbin(x, y, size, orientation, palette, line_color, fill_color, aspect_scale) and returns: r,  bins