class_docstr: Mixin class for Cartesian 2D elements to add basic support for
  SelectionExpr streams.
class_docstr_tok: ["Mixin","class","for","Cartesian","2D","elements","to","add","basic","support","for","SelectionExpr","streams","."]
code: def _get_selection(self, **kwargs):
      xcats, ycats = None, None
      x0, y0, x1, y1 = kwargs["bounds"]
      if "x_selection" in kwargs:
          xsel = kwargs["x_selection"]
          if isinstance(xsel, list):
              xcats = xsel
              x0, x1 = int(round(x0)), int(round(x1))
          ysel = kwargs["y_selection"]
          if isinstance(ysel, list):
              ycats = ysel
              y0, y1 = int(round(y0)), int(round(y1))
  
      # Handle invert_xaxis/invert_yaxis
      if x0 > x1:
          x0, x1 = x1, x0
      if y0 > y1:
          y0, y1 = y1, y0
  
      return (x0, x1), xcats, (y0, y1), ycats
  
imports: import sys
  import numpy
  import pandas
  from ..core import Dataset, NdOverlay, util
  from ..streams import Lasso, Selection1D, SelectionXY
  from ..util.transform import dim
  from .annotation import HSpan, VSpan
label_desc: Use image node_id 2 for calling the Selection2DExpr obj's underlying member method code with example usage: obj._get_selection() and returns: x0,  x1,  xcats,  y0,  y1,  ycats