'Splits up the main data based on discrete aesthetics into sub-data frames'

def _construct_plot_data(self):

    data = self.data
    discrete_aes = self._aes._get_discrete_aes(data)
    mappers = {}
    for (aes_type, colname) in discrete_aes:
        mapper = {}
        if (aes_type in self.scale_identity):
            for item in sorted(data[colname].unique()):
                mapper[item] = item
        else:
            mapping = self._get_mapping(aes_type, colname)
            if (mapping is None):
                continue
            for item in sorted(data[colname].unique()):
                mapper[item] = next(mapping)
        mappers[aes_type] = {u'name': colname, u'lookup': mapper}
        data[((colname + u'_') + aes_type)] = self.data[colname].apply((lambda x: mapper[x]))
        self._aes.data[aes_type] = ((colname + u'_') + aes_type)
    discrete_aes_types = [aes_type for (aes_type, _) in discrete_aes]
    if ((u'color' in self._aes.data) and (u'color' not in discrete_aes_types)):
        if self.colormap:
            self._aes.data[u'colormap'] = cmap = self.colormap
        else:
            self._aes.data[u'colormap'] = cmap = LinearSegmentedColormap.from_list(u'gradient2n', [u'#1f3347', u'#469cef'])
        colname = self._aes.data[u'color']
        quantiles_actual = quantiles = data[colname].quantile([0.0, 0.2, 0.4, 0.5, 0.6, 0.75, 1.0])
        quantiles = ((quantiles - quantiles.min()) / quantiles.max())
        mappers[u'color'] = {u'name': colname, u'lookup': {}}
        colors = cmap(quantiles)
        for (i, q) in enumerate(quantiles_actual):
            mappers[u'color'][u'lookup'][q] = colors[i]
        data[colname] = ((data[colname] - data[colname].min()) / data[colname].max())
    if ((u'alpha' in self._aes.data) and (u'alpha' not in discrete_aes_types)):
        colname = self._aes.data[u'alpha']
        quantiles = data[colname].quantile([0.0, 0.2, 0.4, 0.5, 0.6, 0.75, 0.95])
        quantiles_scaled = ((quantiles - quantiles.min()) / quantiles.max())
        mappers[u'alpha'] = {u'name': colname, u'lookup': dict(zip(quantiles.values, quantiles_scaled.values))}
        data[colname] = ((data[colname] - data[colname].min()) / data[colname].max())
        discrete_aes.append((u'alpha', colname))
    if ((u'size' in self._aes.data) and (u'size' not in discrete_aes_types)):
        colname = self._aes.data[u'size']
        quantiles = data[colname].quantile([0.0, 0.2, 0.4, 0.5, 0.6, 0.75, 0.95])
        quantiles_scaled = ((quantiles - quantiles.min()) / quantiles.max())
        mappers[u'size'] = {u'name': colname, u'lookup': dict(zip(quantiles.values, (100 * quantiles_scaled.values)))}
        data[colname] = ((100 * (data[colname] - data[colname].min())) / data[colname].max())
        discrete_aes.append((u'size', colname))
    groups = [column for (_, column) in discrete_aes]
    if groups:
        return (mappers, data.groupby(groups))
    else:
        return (mappers, [(0, data)])
