class_docstr: List of scales
  
  This class has methods the simplify the handling of
  the ggplot object scales
class_docstr_tok: ["List","of","scales","This","class","has","methods","the","simplify","the","handling","of","the","ggplot","object","scales"]
docstr: Add default scales for the aesthetics if there is none
  
  Scales are added only if the aesthetic is mapped to
  a column in the dataframe. This function may have to be
  called separately after evaluating the aesthetics.
docstr_tok: ["Add","default","scales","for","the","aesthetics","if","there","is","none","Scales","are","added","only","if","the","aesthetic","is","mapped","to","a","column","in","the","dataframe",".","This","function","may","have","to","be","called","separately","after","evaluating","the","aesthetics","."]
code: def add_defaults(self, data, aesthetics):
      """
      Add default scales for the aesthetics if there is none
  
      Scales are added only if the aesthetic is mapped to
      a column in the dataframe. This function may have to be
      called separately after evaluating the aesthetics.
      """
      if not aesthetics:
          return
  
      # aesthetics with scales
      aws = set()
      if self:
          for s in (set(sc.aesthetics) for sc in self):
              aws.update(s)
  
      # aesthetics that do not have scales present
      # We preserve the order of the aesthetics
      new_aesthetics = [x for x in aesthetics if x not in aws]
      if not new_aesthetics:
          return
  
      # If a new aesthetic corresponds to a column in the data
      # frame, find a default scale for the type of data in that
      # column
      seen = set()
      for ae in new_aesthetics:
          col = aesthetics[ae]
          if col not in data:
              col = ae
          scale_var = aes_to_scale(ae)
  
          if self.get_scales(scale_var):
              continue
  
          seen.add(scale_var)
          try:
              sc = make_scale(scale_var, data[col])
          except PlotnineError:
              # Skip aesthetics with no scales (e.g. group, order, etc)
              continue
          self.append(sc)
  
imports: from __future__ import annotations
  import itertools
  import typing
  from contextlib import suppress
  from typing import List
  from warnings import warn
  import numpy
  import pandas.api.types
  from .._utils import array_kind
  from .._utils.registry import Registry
  from ..exceptions import PlotnineError, PlotnineWarning
  from ..mapping.aes import aes_to_scale
  from .scale import scale
label_desc: Use image node_id 16 for calling the Scales obj's underlying member method code with example usage: obj.add_defaults(data, aesthetics) without return types