docstr: Get factors for categorical axes.
docstr_tok: ["Get","factors","for","categorical","axes","."]
code: def _get_coords(self, element, ranges, as_string=True):
      """
      Get factors for categorical axes.
      """
      gdim = None
      sdim = None
      if element.ndims == 1:
          pass
      elif not self.stacked:
          gdim = element.get_dimension(1)
      else:
          sdim = element.get_dimension(1)
  
      xdim, ydim = element.dimensions()[:2]
  
      xvals = None
      if xdim.values:
          xvals = xdim.values
  
      if gdim and not sdim:
          if not xvals and not gdim.values:
              xvals, gvals = categorical_aggregate2d._get_coords(
                  element
              )
          else:
              if gdim.values:
                  gvals = gdim.values
              elif ranges.get(gdim.name, {}).get("factors") is not None:
                  gvals = ranges[gdim.name]["factors"]
              else:
                  gvals = element.dimension_values(gdim, False)
              gvals = np.asarray(gvals)
              if xvals:
                  pass
              elif ranges.get(xdim.name, {}).get("factors") is not None:
                  xvals = ranges[xdim.name]["factors"]
              else:
                  xvals = element.dimension_values(0, False)
              xvals = np.asarray(xvals)
          c_is_str = xvals.dtype.kind in "SU" or not as_string
          g_is_str = gvals.dtype.kind in "SU" or not as_string
          xvals = [
              x if c_is_str else xdim.pprint_value(x) for x in xvals
          ]
          gvals = [
              g if g_is_str else gdim.pprint_value(g) for g in gvals
          ]
          return xvals, gvals
      else:
          if xvals:
              pass
          elif ranges.get(xdim.name, {}).get("factors") is not None:
              xvals = ranges[xdim.name]["factors"]
          else:
              xvals = element.dimension_values(0, False)
          xvals = np.asarray(xvals)
          c_is_str = xvals.dtype.kind in "SU" or not as_string
          xvals = [
              x if c_is_str else xdim.pprint_value(x) for x in xvals
          ]
          return xvals, None
  
imports: import numpy
  from ..core import Dataset, Dimension, util
  from ..element import Bars, Graph
  from ..element.util import categorical_aggregate2d
  from .util import get_axis_padding
label_desc: Use image node_id 3 for calling the BarsMixin obj's underlying member method code with example usage: obj._get_coords(element, ranges, as_string) and returns: xvals,  gvals, xvals,  None