class_docstr: Layer
  
  When a `geom` or `stat` is added to a [](`~plotnine.ggplot`) object,
  it creates a single layer. This class is a representation of that layer.
  
  Parameters
  ----------
  geom :
      geom to used to draw this layer.
  stat :
      stat used for the statistical transformation of
      data in this layer
  mapping :
      Aesthetic mappings.
  data :
      Data plotted in this layer. If `None`, the data from
      the [](`~plotnine.ggplot`) object will be used.
  position :
      Position object to adjust the geometries in this layer.
  inherit_aes :
      If `True` inherit from the aesthetic mappings of
      the [](`~plotnine.ggplot`) object.
  show_legend :
      Whether to make up and show a legend for the mappings
      of this layer. If `None` then an automatic/good choice
      is made
  raster :
      If `True`, draw onto this layer a raster (bitmap) object
      even if the final image format is vector.
  
  Notes
  -----
  There is no benefit to manually creating a layer. You should
  always use a `geom` or `stat`.
class_docstr_tok: ["Layer","When","a","`","geom","`","or","`","stat","`","is","added","to","a","[","]","(","`","~plotnine.ggplot","`",")","object",",","it","creates","a","single","layer",".","This","class","is","a","representation","of","that","layer",".","Parameters","--","--","--","--","--","geom",":","geom","to","used","to","draw","this","layer",".","stat",":","stat","used","for","the","statistical","transformation","of","data","in","this","layer","mapping",":","Aesthetic","mappings",".","data",":","Data","plotted","in","this","layer",".","If","`","None","`",",","the","data","from","the","[","]","(","`","~plotnine.ggplot","`",")","object","will","be","used",".","position",":","Position","object","to","adjust","the","geometries","in","this","layer",".","inherit_aes",":","If","`","True","`","inherit","from","the","aesthetic","mappings","of","the","[","]","(","`","~plotnine.ggplot","`",")","object",".","show_legend",":","Whether","to","make","up","and","show","a","legend","for","the","mappings","of","this","layer",".","If","`","None","`","then","an","automatic\/good","choice","is","made","raster",":","If","`","True","`",",","draw","onto","this","layer","a","raster","(","bitmap",")","object","even","if","the","final","image","format","is","vector",".","Notes","--","--","-","There","is","no","benefit","to","manually","creating","a","layer",".","You","should","always","use","a","`","geom","`","or","`","stat","`","."]
docstr: Mapping aesthetics to computed statistics
docstr_tok: ["Mapping","aesthetics","to","computed","statistics"]
code: def map_statistic(self, plot: Ggplot):
      """
      Mapping aesthetics to computed statistics
      """
      # Mixin default stat aesthetic mappings
      calculated = self.mapping.inherit(
          self.stat.DEFAULT_AES
      )._calculated
  
      if not len(self.data) or not calculated:
          return
  
      # The statistics are calculated in transformed space, but
      # we evaluate the mapping to them in data space.
      # NOTE: If the inverse-retransform turn out to be slow
      # we can try applying them to only the required columns.
      data = plot.scales.inverse_df(self.data)
      stat_data = evaluate(calculated, data, plot.environment)
  
      # If there are duplicate columns, we use the computed
      # ones in stat_data
      columns = data.columns.difference(stat_data.columns)
      data = pd.concat([data[columns], stat_data], axis=1)
  
      self.data = plot.scales.transform_df(data)
  
      # Add any new scales, if needed
      new = {ae: ae for ae in stat_data.columns}
      plot.scales.add_defaults(self.data, new)
  
imports: from __future__ import annotations
  import typing
  from copy import copy, deepcopy
  from typing import Iterable, List, cast, overload
  import pandas
  from ._utils import array_kind, check_required_aesthetics, ninteraction
  from .exceptions import PlotnineError
  from .mapping.aes import NO_GROUP, SCALED_AESTHETICS, aes
  from .mapping.evaluation import evaluate, stage
label_desc: Use image node_id 11 for calling the layer obj's underlying member method code with example usage: obj.map_statistic(plot) without return types