code: def generate_data(self, plot_data):
          
          # Each layer that does not have data gets a copy of
          # of the ggplot.data. If the has data it is replaced
          # by copy so that we do not alter the users data
          if self.data is None:
              self.data = plot_data.copy()
          elif hasattr(self.data, '__call__'):
              self.data = self.data(plot_data)
              if not isinstance(self.data, pd.DataFrame):
                  raise PlotnineError(
                      "Data function must return a dataframe")
          else:
              self.data = self.data.copy()
docs: Generate data to be used by this layer
  
          Parameters
          ----------
          plot_data : dataframe
              ggplot object data