当前位置: 首页>>代码示例>>Python>>正文


Python Normalize.inverse方法代码示例

本文整理汇总了Python中matplotlib.colors.Normalize.inverse方法的典型用法代码示例。如果您正苦于以下问题:Python Normalize.inverse方法的具体用法?Python Normalize.inverse怎么用?Python Normalize.inverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.colors.Normalize的用法示例。


在下文中一共展示了Normalize.inverse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from matplotlib.colors import Normalize [as 别名]
# 或者: from matplotlib.colors.Normalize import inverse [as 别名]
    def __init__(self, cmap, vmin, vmax=None, label=True, label_position=None,
                 label_rotation=None,
                 clipmin=None, clipmax=None, orientation='horizontal',
                 unit=None, contours=(), width=None, ticks=None, threshold=None,
                 ticklocation='auto', background='white', tight=True,
                 h=None, w=None, *args, **kwargs):
        # get Colormap
        if isinstance(cmap, np.ndarray):
            if threshold is not None:
                raise NotImplementedError("threshold parameter with cmap=array")
            if cmap.max() > 1:
                cmap = cmap / 255.
            cm = mpl.colors.ListedColormap(cmap, 'LUT')
        else:
            cm = mpl.cm.get_cmap(cmap)

        # prepare layout
        if orientation == 'horizontal':
            if h is None and w is None:
                h = 1
            ax_aspect = 4
        elif orientation == 'vertical':
            if h is None and w is None:
                h = 4
            ax_aspect = 0.3
        else:
            raise ValueError("orientation=%s" % repr(orientation))

        layout = Layout(1, ax_aspect, 2, tight, False, h, w, *args, **kwargs)
        EelFigure.__init__(self, cm.name, layout)
        ax = self._axes[0]

        # translate between axes and data coordinates
        if isinstance(vmin, Normalize):
            norm = vmin
        else:
            vmin, vmax = fix_vlim_for_cmap(vmin, vmax, cm.name)
            norm = Normalize(vmin, vmax)

        # value ticks
        if ticks is False:
            ticks = ()
            tick_labels = None
        elif isinstance(ticks, dict):
            tick_dict = ticks
            ticks = sorted(tick_dict)
            tick_labels = [tick_dict[t] for t in ticks]
        else:
            tick_labels = None

        if orientation == 'horizontal':
            axis = ax.xaxis
            contour_func = ax.axhline
        else:
            axis = ax.yaxis
            contour_func = ax.axvline

        if label is True:
            if unit:
                label = unit
            else:
                label = cm.name
        elif not label:
            label = ''

        # show only part of the colorbar
        if clipmin is not None or clipmax is not None:
            if isinstance(norm, SymmetricNormalize):
                raise NotImplementedError(
                    "clipmin or clipmax with SymmetricNormalize")
            boundaries = norm.inverse(np.linspace(0, 1, cm.N + 1))
            if clipmin is None:
                start = None
            else:
                start = np.digitize(clipmin, boundaries, True)
            if clipmax is None:
                stop = None
            else:
                stop = np.digitize(clipmax, boundaries) + 1
            boundaries = boundaries[start:stop]
        else:
            boundaries = None

        colorbar = ColorbarBase(ax, cm, norm, boundaries=boundaries,
                                orientation=orientation,
                                ticklocation=ticklocation, ticks=ticks,
                                label=label)

        # fix tick location
        if isinstance(norm, SymmetricNormalize) and ticks is not None:
            tick_norm = Normalize(norm.vmin, norm.vmax, norm.clip)
            axis.set_ticks(tick_norm(ticks))

        # unit-based tick-labels
        if unit and tick_labels is None:
            formatter, label = find_axis_params_data(unit, label)
            tick_labels = tuple(map(formatter, colorbar.get_ticks()))

        if tick_labels is not None:
            if clipmin is not None:
#.........这里部分代码省略.........
开发者ID:christianbrodbeck,项目名称:Eelbrain,代码行数:103,代码来源:_colors.py


注:本文中的matplotlib.colors.Normalize.inverse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。