code: def _get_fun_data(mapping, data, fun, xlim, n):
      aes_x_value = None
      if mapping is not None and "x" in mapping.as_dict():
          aes_x_value = mapping.as_dict()["x"]
  
      if isinstance(aes_x_value, str) and data is not None:
          xs = data[aes_x_value]
      elif hasattr(aes_x_value, "__iter__"):
          xs = aes_x_value
      else:
          xs = _get_default_xrange(xlim, n)
  
      if fun is None:
          ys = [None] * len(xs)
      else:
          ys = [fun(x) for x in xs]
  
      if data is None:
          return {_fun_x_name: xs, _fun_y_name: ys}
      else:
          if isinstance(data, dict):
              return {**data, **{_fun_y_name: ys}}
          elif pd is not None and isinstance(data, pd.DataFrame):
              return data.assign(**{_fun_y_name: ys})
          elif pl is not None and isinstance(data, pl.DataFrame):
              return data.with_columns(
                  **{_fun_y_name: pl.Series(values=ys)}
              )
          else:
              raise Exception(
                  "Unsupported type of data: {0}".format(data)
              )
  
imports: from .core import aes
  from .geom import _geom
label_desc: Use image node_id 3 for calling a global function with example usage: _get_fun_data(mapping, data, fun, xlim, n) and returns: dict, dict, data, data