コード例 #1
0
ファイル: _cm_tools.py プロジェクト: zcl-maker/Viscid
def register_cmap(name, colors, reverse=False):
    """Register a cmap given a name and either a cmap or an Nx3 or Nx4
    ndarray or rgb(a) data.

    Calls to_linear_cmap(colors) before registering.

    Args:
        name (str, None): if None, name = colors.name; this will not
            play nicely with an ndarray
        colors (Colormap or ndarray): colors as either a matplotlib
            Colormap or an Nx3 or Nx4 ndarray or rgb(a) data
        reverse (bool): flip the lower and upper ends of the mapping
    """
    if name is None:
        name = colors.name
    cmap = to_linear_cmap(name, colors, reverse=reverse)
    _register_cmap(name=name, cmap=cmap)
コード例 #2
0
ファイル: cmap_tools.py プロジェクト: jobejen/Viscid
def register_cmap(name, colors, reverse=False):
    """Register a cmap given a name and either a cmap or an Nx3 or Nx4
    ndarray or rgb(a) data.

    Calls to_linear_cmap(colors) before registering.

    Args:
        name (str, None): if None, name = colors.name; this will not
            play nicely with an ndarray
        colors (Colormap or ndarray): colors as either a matplotlib
            Colormap or an Nx3 or Nx4 ndarray or rgb(a) data
        reverse (bool): flip the lower and upper ends of the mapping
    """
    if name is None:
        name = colors.name
    cmap = to_linear_cmap(name, colors, reverse=reverse)
    _register_cmap(name=name, cmap=cmap)
コード例 #3
0
warnings.filterwarnings("ignore")

from datascience import Table as _Table
import numpy as _np
import matplotlib.pyplot as _plt
from matplotlib.ticker import MultipleLocator as _MultipleLocator
from matplotlib.collections import PolyCollection as _PC
from matplotlib.colors import LinearSegmentedColormap as _LinearSegmentedColormap
from matplotlib.cm import register_cmap as _register_cmap
from IPython.display import display as _display

cmap = _plt.get_cmap('Dark2')
cmap_4thdownbot = _LinearSegmentedColormap.from_list('4thdownbot_cmap',
                                                     cmap.colors[:3],
                                                     N=3)
_register_cmap(name='4thdownbot_cmap', cmap=cmap_4thdownbot)


def display_re_matrix(re):
    _display(re.unstack(level=0).sort_values(by=0))


def display_weights(w):
    _display(w.to_frame().transpose())


def fast_run_expectancy(retro, re):
    TABLE_FLAG = False
    if isinstance(retro, _Table):
        TABLE_FLAG = True
        retro = retro.to_df()