docs: def plot_elements_to_ax(self, cid, ax=None, **kwargs):
          """Plot element data (parameter sets).
  
          If the parameter *ax* is not set, then a new figure will be created
          with a corresponding axes.
  
  
          Parameters
          ----------
          cid : int or :py:class:`numpy.ndarray`
              if *cid* is an int, then treat it as the id of the parameter set
              stored in self.parman. Otherwise, expect it to be the data to plot.
              At the moment no checks are made that the data fits the grid.
          ax : matplotlib.Axes, optional
              plot to this axes object, if provided
          alpha_cid : int, optional
              if given, use the corresponding dataset in self.parman as the alpha
              channel. No checks are made if all values of this data set lie
              between 0 and 1 (0 being fully transparent, and 1 being opaque).
          xmin : float, optional
              minimal x limit to plot
          xmax : float, optional
              maximal x limit to plot
          zmin : float, optional
              minimal z limit to plot
          zmax : float, optional
              maximial z limit to plot
          converter : function, optional
              if given, then use this function to convert the data into another
              representation. The given function must work with a numpy array.
              Default: None
          norm : norm object, optional
              the norm object for matplotlib plotting can be provided here
          cmap_name : string, optional
              name of the colorbar to use. Default is "viridis". To reverse
              colors, use the _r version "viridis_r"
          cbposition : ?
              ?
          cblabel : string, optional
              colorbar label
          cbsegments : int, optional
              ?
          cbnrticks : int, optional
              ?
          over : color, optional
              color to use for values above the current cb-limit. Default: ?
          under :
              color to use for values below the current cb-limit. Default: ?
          bad :
              color to use for nan-values. Default: ?
          plot_colorbar : bool, optional
              if true, plot a colorbar next to the plot
          title : string, optional
              plot title string
          xlabel : string, optional
              Set xlabel of the resulting plot
          ylabel : string, optional
              Set ylabel of the resulting plot
          no_elecs : bool, optional
              If True, plot no electrodes
          rasterize: bool, optional
              if True, rasterize the plot. Default: False
  
          Returns
          -------
          fig:
  
          ax:
  
          cnorm:
  
          cmap:
  
          cb: colorbar instance, optional
              only of plot_colorbar is True
          scalarMap:
              use to create custom colorbars
  
          """
  
          rasterize = kwargs.get('rasterize', False)
          xmin = kwargs.get('xmin', self.grid.grid['x'].min())
          xmax = kwargs.get('xmax', self.grid.grid['x'].max())
          zmin = kwargs.get('zmin', self.grid.grid['z'].min())
          zmax = kwargs.get('zmax', self.grid.grid['z'].max())
  
          # try to create a suitable default figure size
          if ax is None:
              # 15 cm
              sizex = 15 / 2.54
              sizez = sizex * (np.abs(zmax - zmin) / np.abs(xmax - xmin) * 1.1)
              # add 1 inch to accommodate colorbar
              sizez += 1.3
              fig, ax = plt.subplots(figsize=(sizex, sizez))
          else:
              fig = ax.get_figure()
              sizex, sizez = fig.get_size_inches()
  
          # get data
          if isinstance(cid, int):
              subdata = self.parman.parsets[cid]
          else:
              subdata = cid
  
          if 'converter' in kwargs:
              subdata = kwargs['converter'](subdata)
  
          # color map
          cmap_name = kwargs.get('cmap_name', 'viridis')
          cmap = mpl.cm.get_cmap(
              cmap_name,
              kwargs.get('cbsegments', None)
          )
          over = kwargs.get('over', 'orange')
          under = kwargs.get('under', 'mediumblue')
          bad = kwargs.get('bad', 'white')
          cmap.set_over(over)
          cmap.set_under(under)
          cmap.set_bad(bad)
  
          # normalize data
          data_min = kwargs.get('cbmin', subdata.min())
          data_max = kwargs.get('cbmax', subdata.max())
          if(data_min is not None and data_max is not None and
             data_min == data_max):
              data_min -= 1
              data_max += 1
          cnorm = mpl.colors.Normalize(vmin=data_min, vmax=data_max)
          scalarMap = mpl.cm.ScalarMappable(norm=cnorm, cmap=cmap)
          fcolors = scalarMap.to_rgba(subdata)
          scalarMap.set_array(subdata)
  
          # if applicable, apply alpha values
          alpha_cid = kwargs.get('cid_alpha', None)
          if isinstance(alpha_cid, int):
              print('applying alpha')
              alpha = self.parman.parsets[alpha_cid]
              # make sure this data set is normalized between 0 and 1
              if np.nanmin(alpha) < 0 or np.nanmax(alpha) > 1:
                  raise Exception(
                      'alpha data set must be normalized between 0 and 1'
                  )
              fcolors[:, 3] = alpha
  
          all_xz = []
          for x, z in zip(self.grid.grid['x'], self.grid.grid['z']):
              tmp = np.vstack((x, z)).T
              all_xz.append(tmp)
  
          norm = kwargs.get('norm', None)
  
          collection = mpl.collections.PolyCollection(
              all_xz,
              edgecolor=fcolors,
              facecolor=fcolors,
              linewidth=0.0,
              cmap=cmap,
              norm=norm,
              rasterized=rasterize,
          )
          collection.set_cmap(cmap)
          ax.add_collection(collection)
          no_elecs = kwargs.get('no_elecs', False)
          if self.grid.electrodes is not None and no_elecs is not True:
              ax.scatter(
                  self.grid.electrodes[:, 1],
                  self.grid.electrodes[:, 2],
                  color=self.grid.props['electrode_color'],
                  # clip_on=False,
              )
  
          ax.set_xlim(xmin, xmax)
          ax.set_ylim(zmin, zmax)
          ax.set_xlabel(kwargs.get('xlabel', 'x'))
          ax.set_ylabel(kwargs.get('zlabel', 'z'))
          ax.set_aspect('equal')
          ax.set_title(
              kwargs.get('title', '')
          )
  
          if kwargs.get('plot_colorbar', False):
              divider = make_axes_locatable(ax)
              cbposition = kwargs.get('cbposition', 'vertical')
              if cbposition == 'horizontal':
                  ax_cb = divider.new_vertical(
                      size=0.1, pad=0.4, pack_start=True
                  )
              elif cbposition == 'vertical':
                  ax_cb = divider.new_horizontal(
                      size=0.1, pad=0.4,
                  )
              else:
                  raise Exception('cbposition not recognized')
  
              ax.get_figure().add_axes(ax_cb)
  
              cb = fig.colorbar(
                  scalarMap,
                  cax=ax_cb,
                  orientation=cbposition,
                  label=kwargs.get('cblabel', ''),
                  ticks=mpl.ticker.MaxNLocator(kwargs.get('cbnrticks', 3)),
                  format=kwargs.get('cbformat', None),
                  extend='both',
              )
  
              return fig, ax, cnorm, cmap, cb, scalarMap
  
          return fig, ax, cnorm, cmap, scalarMap