コード例 #1
0
ファイル: geom.py プロジェクト: thescoop/ggplot
    def sort_by_x(self, pinfo):
        """
        Sort the lists in pinfo according to pinfo['x']
        This function is useful for geom's that expect
        the x-values to come in sorted order
        """
        # Remove list types from pinfo
        _d = {}
        for k in list(pinfo.keys()):
            if not is_string(pinfo[k]) and iterable(pinfo[k]):
                _d[k] = pinfo.pop(k)

        # Sort numerically if all items can be cast
        try:
            x = list(map(np.float, _d['x']))
        except (ValueError, TypeError):
            x = _d['x']

        # Make sure we don't try to sort something unsortable
        try:
            idx = np.argsort(x)
            # Put sorted lists back in pinfo
            for key in _d:
                pinfo[key] = [_d[key][i] for i in idx]
        except:
            pass
        return pinfo
コード例 #2
0
ファイル: geom_bar.py プロジェクト: BernhardKonrad/ggplot
    def _sort_list_types_by_x(self, pinfo):
        """
        Sort the lists in pinfo according to pinfo['x']
        """
        # Remove list types from pinfo
        _d = {}
        for k in list(pinfo.keys()):
            if not is_string(pinfo[k]) and cbook.iterable(pinfo[k]):
                _d[k] = pinfo.pop(k)

        # Sort numerically if all items can be cast
        try:
            x = list(map(np.float, _d['x']))
        except ValueError:
            x = _d['x']
        idx = np.argsort(x)

        # Put sorted lists back in pinfo
        for key in _d:
            pinfo[key] = [_d[key][i] for i in idx]

        return pinfo
コード例 #3
0
ファイル: geom_bar.py プロジェクト: algo74/predictsim
    def _sort_list_types_by_x(self, pinfo):
        """
        Sort the lists in pinfo according to pinfo['x']
        """
        # Remove list types from pinfo
        _d = {}
        for k in list(pinfo.keys()):
            if not is_string(pinfo[k]) and cbook.iterable(pinfo[k]):
                _d[k] = pinfo.pop(k)

        # Sort numerically if all items can be cast
        try:
            x = list(map(np.float, _d['x']))
        except ValueError:
            x = _d['x']
        idx = np.argsort(x)

        # Put sorted lists back in pinfo
        for key in _d:
            pinfo[key] = [_d[key][i] for i in idx]

        return pinfo