code: def legend_aesthetics(self, layer, plot):
          
          l = layer
          legend_ae = set(self.key.columns) - {'label'}
          all_ae = (l.mapping.keys() |
                    (plot.mapping if l.inherit_aes else set()) |
                    l.stat.DEFAULT_AES.keys())
          geom_ae = l.geom.REQUIRED_AES | l.geom.DEFAULT_AES.keys()
          matched = all_ae & geom_ae & legend_ae
          matched = list(matched - set(l.geom.aes_params))
          return matched
docs: Return the aesthetics that contribute to the legend
  
          Parameters
          ----------
          layer : Layer
              Layer whose legend is to be drawn
          plot : ggplot
              Plot object
  
          Returns
          -------
          matched : list
              List of the names of the aethetics that contribute
              to the legend.