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


Python colors.SymLogNorm方法代码示例

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


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

示例1: test_SymLogNorm

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import SymLogNorm [as 别名]
def test_SymLogNorm():
    """
    Test SymLogNorm behavior
    """
    norm = mcolors.SymLogNorm(3, vmax=5, linscale=1.2)
    vals = np.array([-30, -1, 2, 6], dtype=np.float)
    normed_vals = norm(vals)
    expected = [0., 0.53980074, 0.826991, 1.02758204]
    assert_array_almost_equal(normed_vals, expected)
    _inverse_tester(norm, vals)
    _scalar_tester(norm, vals)
    _mask_tester(norm, vals)

    # Ensure that specifying vmin returns the same result as above
    norm = mcolors.SymLogNorm(3, vmin=-30, vmax=5, linscale=1.2)
    normed_vals = norm(vals)
    assert_array_almost_equal(normed_vals, expected) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:19,代码来源:test_colors.py

示例2: test_SymLogNorm

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import SymLogNorm [as 别名]
def test_SymLogNorm():
    """
    Test SymLogNorm behavior
    """
    norm = mcolors.SymLogNorm(3, vmax=5, linscale=1.2)
    vals = np.array([-30, -1, 2, 6], dtype=float)
    normed_vals = norm(vals)
    expected = [0., 0.53980074, 0.826991, 1.02758204]
    assert_array_almost_equal(normed_vals, expected)
    _inverse_tester(norm, vals)
    _scalar_tester(norm, vals)
    _mask_tester(norm, vals)

    # Ensure that specifying vmin returns the same result as above
    norm = mcolors.SymLogNorm(3, vmin=-30, vmax=5, linscale=1.2)
    normed_vals = norm(vals)
    assert_array_almost_equal(normed_vals, expected) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:19,代码来源:test_colors.py

示例3: norm

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import SymLogNorm [as 别名]
def norm(self, norm):

        if norm == "lin":
            self.pixels.norm = Normalize()
        elif norm == "log":
            self.pixels.norm = LogNorm()
            self.pixels.autoscale()  # this is to handle matplotlib bug #5424
        elif norm == "symlog":
            self.pixels.norm = SymLogNorm(linthresh=1.0)
            self.pixels.autoscale()
        elif isinstance(norm, Normalize):
            self.pixels.norm = norm
        else:
            raise ValueError(
                "Unsupported norm: '{}', options are 'lin',"
                "'log','symlog', or a matplotlib Normalize object".format(norm)
            )

        self.update(force=True)
        self.pixels.autoscale() 
开发者ID:cta-observatory,项目名称:ctapipe,代码行数:22,代码来源:mpl_camera.py

示例4: set_colourbar_norm_type

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import SymLogNorm [as 别名]
def set_colourbar_norm_type(self, colourbar_norm_type):
        if colourbar_norm_type == "SymLogNorm":
            norm = _mcolors.SymLogNorm(linthresh=0.3, vmin=self._vmin, vmax=self._vmax)
        elif colourbar_norm_type is None:
            norm = None
        else:
            raise NotImplementedError("That type of normalisation is not coded in yet..")
            norm = None
        
        return norm 
开发者ID:LSDtopotools,项目名称:LSDMappingTools,代码行数:12,代码来源:drapeplot.py

示例5: build_canvas

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import SymLogNorm [as 别名]
def build_canvas(self):
        # get plot axes and data
        x = self.data.data[0]
        y = self.data.data[1]

        # build color map norm
        if self.cb_scale == "log":
            self.cb_norm = clr.LogNorm(vmin=self.vmin, vmax=self.vmax)
        elif self.cb_scale == "symlog":
            self.cb_norm = clr.SymLogNorm(
                vmin=self.vmin,
                vmax=self.vmax,
                linthresh=self.cb_linthresh,
                base=10,
            )
        else:
            self.cb_norm = clr.Normalize(vmin=self.vmin, vmax=self.vmax)

        # build plot
        self.h = self.axes.ax.scatter(
            x,
            y,
            s=self.s,
            c=self.c,
            marker=self.marker,
            alpha=self.alpha,
            label=self.label,
            cmap=self.cb_map,
            norm=self.cb_norm
            # antialiased=self.antialiased,
        )

        if self.has_cb:
            self.axes.init_colorbar(plot=self) 
开发者ID:GoLP-IST,项目名称:nata,代码行数:36,代码来源:scatter.py

示例6: _get_ticker_locator_formatter

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import SymLogNorm [as 别名]
def _get_ticker_locator_formatter(self):
        """
        This code looks at the norm being used by the colorbar
        and decides what locator and formatter to use.  If ``locator`` has
        already been set by hand, it just returns
        ``self.locator, self.formatter``.
        """
        locator = self.locator
        formatter = self.formatter
        if locator is None:
            if self.boundaries is None:
                if isinstance(self.norm, colors.NoNorm):
                    nv = len(self._values)
                    base = 1 + int(nv / 10)
                    locator = ticker.IndexLocator(base=base, offset=0)
                elif isinstance(self.norm, colors.BoundaryNorm):
                    b = self.norm.boundaries
                    locator = ticker.FixedLocator(b, nbins=10)
                elif isinstance(self.norm, colors.LogNorm):
                    locator = _ColorbarLogLocator(self)
                elif isinstance(self.norm, colors.SymLogNorm):
                    # The subs setting here should be replaced
                    # by logic in the locator.
                    locator = ticker.SymmetricalLogLocator(
                                      subs=np.arange(1, 10),
                                      linthresh=self.norm.linthresh,
                                      base=10)
                else:
                    if mpl.rcParams['_internal.classic_mode']:
                        locator = ticker.MaxNLocator()
                    else:
                        locator = _ColorbarAutoLocator(self)
            else:
                b = self._boundaries[self._inside]
                locator = ticker.FixedLocator(b, nbins=10)
        _log.debug('locator: %r', locator)
        return locator, formatter 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:39,代码来源:colorbar.py

示例7: test_SymLogNorm_colorbar

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import SymLogNorm [as 别名]
def test_SymLogNorm_colorbar():
    """
    Test un-called SymLogNorm in a colorbar.
    """
    norm = mcolors.SymLogNorm(0.1, vmin=-1, vmax=1, linscale=1)
    fig = plt.figure()
    cbar = mcolorbar.ColorbarBase(fig.add_subplot(111), norm=norm)
    plt.close(fig) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:10,代码来源:test_colors.py

示例8: test_SymLogNorm_single_zero

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import SymLogNorm [as 别名]
def test_SymLogNorm_single_zero():
    """
    Test SymLogNorm to ensure it is not adding sub-ticks to zero label
    """
    fig = plt.figure()
    norm = mcolors.SymLogNorm(1e-5, vmin=-1, vmax=1)
    cbar = mcolorbar.ColorbarBase(fig.add_subplot(111), norm=norm)
    ticks = cbar.get_ticks()
    assert sum(ticks == 0) == 1
    plt.close(fig) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:12,代码来源:test_colors.py

示例9: test_ndarray_subclass_norm

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import SymLogNorm [as 别名]
def test_ndarray_subclass_norm(recwarn):
    # Emulate an ndarray subclass that handles units
    # which objects when adding or subtracting with other
    # arrays. See #6622 and #8696
    class MyArray(np.ndarray):
        def __isub__(self, other):
            raise RuntimeError

        def __add__(self, other):
            raise RuntimeError

    data = np.arange(-10, 10, 1, dtype=float)
    data.shape = (10, 2)
    mydata = data.view(MyArray)

    for norm in [mcolors.Normalize(), mcolors.LogNorm(),
                 mcolors.SymLogNorm(3, vmax=5, linscale=1),
                 mcolors.Normalize(vmin=mydata.min(), vmax=mydata.max()),
                 mcolors.SymLogNorm(3, vmin=mydata.min(), vmax=mydata.max()),
                 mcolors.PowerNorm(1)]:
        assert_array_equal(norm(mydata), norm(data))
        fig, ax = plt.subplots()
        ax.imshow(mydata, norm=norm)
        fig.canvas.draw()
        assert len(recwarn) == 0
        recwarn.clear() 
开发者ID:holzschu,项目名称:python3_ios,代码行数:28,代码来源:test_colors.py

示例10: plot

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import SymLogNorm [as 别名]
def plot(self):
        '''Replot the colorbar.'''
        if self.cmap is None:
            return

        self.ax.cla()
        self.cax.cla()
        cmap = self.cmap
        if 'norm' not in cmap or cmap['norm'] is None:
            self.norm_type.setCurrentIndex(0)
        else:
            norm_name = cmap['norm'].__class__.__name__
            if norm_name == 'Normalize':
                self.norm_type.setCurrentIndex(1)
            elif norm_name == 'LogNorm':
                self.norm_type.setCurrentIndex(2)
            elif norm_name == 'SymLogNorm':
                self.norm_type.setCurrentIndex(3)
            elif norm_name == 'PowerNorm':
                self.norm_type.setCurrentIndex(4)
            elif norm_name == 'BoundaryNorm':
                self.norm_type.setCurrentIndex(5)

        if cmap is not None:
            if 'norm' in cmap:
                norm = cmap['norm']
            else:
                norm = None
            im = self.ax.imshow(gradient, aspect='auto', cmap=cmap['cmap'],
                                vmin=cmap['vmin'], vmax=cmap['vmax'],
                                norm=norm)
            plt.colorbar(im, cax=self.cax)

        self.canvas.draw() 
开发者ID:nguy,项目名称:artview,代码行数:36,代码来源:cmap.py

示例11: update_colormap

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import SymLogNorm [as 别名]
def update_colormap(self):
        '''Get colormap from GUI.'''
        self.cmap['lock'] = self.lock_box.isChecked()
        idx = self.norm_type.currentIndex()

        self.cmap['vmin'] = float(self.ent_vmin.text())
        self.cmap['vmax'] = float(self.ent_vmax.text())

        if idx == 0:
            self.cmap['norm'] = None
        elif idx == 1:
            self.cmap['norm'] = colors.Normalize(vmin=self.cmap['vmin'],
                                                 vmax=self.cmap['vmax'])
        elif idx == 2:
            self.cmap['norm'] = colors.LogNorm(vmin=self.cmap['vmin'],
                                               vmax=self.cmap['vmax'])
        elif idx == 3:
            self.cmap['norm'] = colors.SymLogNorm(
                linthresh=float(self.ent_linthresh.text()),
                linscale=float(self.ent_linscale.text()),
                vmin=self.cmap['vmin'],
                vmax=self.cmap['vmax'])
        elif idx == 4:
            self.cmap['norm'] = colors.PowerNorm(
                gamma=float(self.ent_gamma.text()),
                vmin=self.cmap['vmin'],
                vmax=self.cmap['vmax'])
        elif idx == 5:
            bounds = self.get_bounds()
            self.cmap['norm'] = colors.BoundaryNorm(bounds,
                                                    ncolors=256)
        self.plot() 
开发者ID:nguy,项目名称:artview,代码行数:34,代码来源:cmap.py

示例12: show_state_map

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import SymLogNorm [as 别名]
def show_state_map(title, agent_name, values, state_limits, v_max=None):
    fig, ax = plt.subplots()
    img = ax.imshow(values.T,
                    extent=(-state_limits, state_limits, -state_limits, state_limits),
                    norm=colors.SymLogNorm(linthresh=1, linscale=1, vmax=v_max),
                    cmap=plt.cm.coolwarm)
    fig.colorbar(img, ax=ax)
    plt.grid(False)
    plt.title(rename(agent_name))
    plt.savefig(out / "{}_{}.pdf".format(title, agent_name))
    plt.show() 
开发者ID:eleurent,项目名称:rl-agents,代码行数:13,代码来源:planners_visualization.py

示例13: __plot_matrix

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import SymLogNorm [as 别名]
def __plot_matrix(self, genome_range):
        start, end = genome_range.start, genome_range.end
        ax = self.ax
        arr = self.matrix
        if isinstance(self.properties['color'], str):
            cmap = plt.get_cmap(self.properties['color'])
        else:
            cmap = self.properties['color']
        cmap.set_bad("white")
        cmap.set_under("white")
        c_min_1, c_max_1 = self.hic1.matrix_val_range
        c_min_2, c_max_2 = self.hic2.matrix_val_range

        self.small_value = ( abs(c_min_1) + abs(c_min_2) ) / 2

        if self.properties['norm'] == 'log':
            a_ = np.log10(c_max_1)
            b_ = np.log10(c_max_2)
            c_ = np.log10(self.small_value)
            ra_ = abs(c_ - a_) + 0.7
            rb_ = abs(c_ - b_) + 0.7

            midpoint = (ra_ / (ra_ + rb_))
        else:
            midpoint = (abs(c_max_2) / (abs(c_max_1) + abs(c_max_2)))

        cmap = shiftedColorMap(cmap, midpoint=midpoint)

        img = ax.matshow(arr, cmap=cmap,
                         extent=(start, end, end, start),
                         aspect='auto')

        if self.properties['norm'] == 'log':
            img.set_norm(colors.SymLogNorm(linthresh=self.small_value, linscale=1, vmin=-c_max_1, vmax=c_max_2))
        else:
            img.set_norm(colors.Normalize(vmin=-c_max_1, vmax=c_max_2))

        return img 
开发者ID:GangCaoLab,项目名称:CoolBox,代码行数:40,代码来源:hiccompare.py

示例14: plot_embedding

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import SymLogNorm [as 别名]
def plot_embedding(spec, path):
    spec = spec.transpose(1, 0) # (seq_len, feature_dim) -> (feature_dim, seq_len)
    plt.gcf().clear()
    plt.figure(figsize=(12, 3))
    plt.pcolormesh(spec, norm=SymLogNorm(linthresh=1e-3))
    plt.colorbar()
    plt.tight_layout()
    plt.savefig(path, dpi=300, format="png")
    plt.close() 
开发者ID:andi611,项目名称:Self-Supervised-Speech-Pretraining-and-Representation-Learning,代码行数:11,代码来源:audio.py

示例15: test_ndarray_subclass_norm

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import SymLogNorm [as 别名]
def test_ndarray_subclass_norm(recwarn):
    # Emulate an ndarray subclass that handles units
    # which objects when adding or subtracting with other
    # arrays. See #6622 and #8696
    class MyArray(np.ndarray):
        def __isub__(self, other):
            raise RuntimeError

        def __add__(self, other):
            raise RuntimeError

    data = np.arange(-10, 10, 1, dtype=float)
    data.shape = (10, 2)
    mydata = data.view(MyArray)

    for norm in [mcolors.Normalize(), mcolors.LogNorm(),
                 mcolors.SymLogNorm(3, vmax=5, linscale=1),
                 mcolors.Normalize(vmin=mydata.min(), vmax=mydata.max()),
                 mcolors.SymLogNorm(3, vmin=mydata.min(), vmax=mydata.max()),
                 mcolors.PowerNorm(1)]:
        assert_array_equal(norm(mydata), norm(data))
        fig, ax = plt.subplots()
        ax.imshow(mydata, norm=norm)
        fig.canvas.draw()
        if isinstance(norm, mcolors.PowerNorm):
            assert len(recwarn) == 1
            warn = recwarn.pop(UserWarning)
            assert ('Power-law scaling on negative values is ill-defined'
                    in str(warn.message))
        else:
            assert len(recwarn) == 0
        recwarn.clear() 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:34,代码来源:test_colors.py


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