class_docstr: A histogram of a categorial field.
  
  Args:
      field_or_expr: a field name, ``embedded.field.name``,
          :class:`fiftyone.core.expressions.ViewExpression`, or
          `MongoDB expression <https://docs.mongodb.com/manual/meta/aggregation-quick-reference/#aggregation-expressions>`_
          defining the field or expression to plot
      expr (None): an optional
          :class:`fiftyone.core.expressions.ViewExpression` or
          `MongoDB expression <https://docs.mongodb.com/manual/meta/aggregation-quick-reference/#aggregation-expressions>`_
          to apply to ``field_or_expr`` (which must be a field) before
          plotting
      order ("alphabetical"): the x-axis ordering strategy to use. Can be
          "alphabetical" to sort by field value, or "frequency" to sort in
          descending order of frequency, or a function suitable for
          ``sorted(items, key=order)``, where ``items`` is a list of
          ``(value, count)`` tuples
      xlabel (None): an optional x-label for the plot
      log (False): whether to use a log scale y-axis
      bargap (None): relative spacing between bars in ``[0, 1]``
      color (None): a color for the bars. Can be any color supported by
          :meth:`plotly:plotly.graph_objects.bar.Marker.color`
      opacity (None): an optional opacity for the bars in ``[0, 1]``
      init_view (None): an optional initial
          :class:`fiftyone.core.collections.SampleCollection` to load
      **kwargs: optional parameters for
          :meth:`plotly:plotly.graph_objects.Figure.update_layout`
code: def __init__(
      self,
      field_or_expr,
      expr=None,
      order="alphabetical",
      xlabel=None,
      log=None,
      bargap=None,
      color=None,
      opacity=None,
      init_view=None,
      **kwargs,
  ):
      self.field_or_expr = field_or_expr
      self.expr = expr
      self.order = order
      self.xlabel = xlabel
      self.log = log
      self.bargap = bargap
      self.color = color
      self.opacity = opacity
      self.layout = kwargs
  
      if order == "alphabetical":
          self._order = itemgetter(0)
          self._reverse = False
      elif order == "frequency":
          self._order = itemgetter(1)
          self._reverse = True
      else:
          self._order = order
          self._reverse = False
  
      self._figure = self._make_histogram()
  
      self._aggregations = [foa.CountValues(field_or_expr, expr=expr)]
  
      widget = self._make_widget()
  
      super().__init__(widget, init_view=init_view)
  
imports: import itertools
  from operator import itemgetter
  import numpy
  import eta.core.utils
  import plotly.subplots
  import plotly.graph_objects
  import fiftyone.core.aggregations
  from .base import ViewPlot
  from .plotly import PlotlyWidgetMixin
label_desc: Use image node_id 1 to create a new CategoricalHistogram object from inherited base classes: PlotlyViewPlot with example: obj = CategoricalHistogram(field_or_expr, expr, order, xlabel, log, bargap, color, opacity, init_view)