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: Train the scales on the data.
  
  The scales should be for the same aesthetic
  e.g. x scales, y scales, color scales, ...
  
  Parameters
  ----------
  data : dataframe
      data to use for training
  vars : list | tuple
      columns in data to use for training.
      These should be all the aesthetics of
      a scale type that are present in the
      data. e.g x, xmin, xmax
  idx : array_like
      indices that map the data points to the
      scales. These start at 1, so subtract 1 to
      get the true index into the scales array
docstr_tok: ["Train","the","scales","on","the","data",".","The","scales","should","be","for","the","same","aesthetic","e.g",".","x","scales",",","y","scales",",","color","scales",",","...","Parameters","--","--","--","--","--","data",":","dataframe","data","to","use","for","training","vars",":","list","|","tuple","columns","in","data","to","use","for","training",".","These","should","be","all","the","aesthetics","of","a","scale","type","that","are","present","in","the","data",".","e.g","x",",","xmin",",","xmax","idx",":","array_like","indices","that","map","the","data","points","to","the","scales",".","These","start","at","1",",","so","subtract","1","to","get","the","true","index","into","the","scales","array"]
code: def train(self, data, vars, idx):
      """
      Train the scales on the data.
  
      The scales should be for the same aesthetic
      e.g. x scales, y scales, color scales, ...
  
      Parameters
      ----------
      data : dataframe
          data to use for training
      vars : list | tuple
          columns in data to use for training.
          These should be all the aesthetics of
          a scale type that are present in the
          data. e.g x, xmin, xmax
      idx : array_like
          indices that map the data points to the
          scales. These start at 1, so subtract 1 to
          get the true index into the scales array
      """
      idx = np.asarray(idx)
      for col in vars:
          for i, sc in enumerate(self, start=1):
              bool_idx = i == idx
              sc.train(data.loc[bool_idx, col])
  
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 9 for calling the Scales obj's underlying member method code with example usage: obj.train(data, vars, idx) without return types